AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[mvc](server)

Martin Hope
Andreas Witte
Asked: 2016-09-03 01:21:19 +0800 CST

在 nginx 中生成 .css 文件

  • 0

我在 apache 上开发,现在我需要在 ngix 上部署,我遇到了一些困难。因为在我的项目中禁用了内联样式(使用 cakephp)并且在数据库中定义了一些颜色,所以我让 RsrcController 生成带有颜色的 css 到模板中。

仅当我不使用文件扩展名 .css 时调用此函数才有效,而仅使用带有控制器和函数的斜线 Url。

如果我附加以 .css 结尾的文件,则 nginx 将在 webroot 文件夹中搜索并返回 404。

这是配置的相关部分:

        location / {
            try_files $uri $uri/ /index.php?$args;
        }


        #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
           try_files $uri =404;
           include /etc/nginx/fastcgi_params;
           fastcgi_pass    127.0.0.1:9000;
           fastcgi_index   index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }

我试图找到一个添加另一个位置规则的解决方案,如下所示:

location ~ rsrc/css_vars/~.css {
    ... [->second part of my question]
}

我不想将所有 .css 文件传递​​给 php。只是那些我希望是动态生成的。无论如何,我的更改似乎不起作用。

第二部分:

Cakephp 的工作方式如下:http : //url.com/controller/function/var1/var2/varx 我的控制器是 rsrc。我的函数是 css_vars。比有一些变量(用户......),最后我需要“.css”。

我想将 URl 重写为相同但没有文件扩展名“.css”。有没有办法解决正则表达式?

nginx css cakephp mvc
  • 2 个回答
  • 324 Views
Martin Hope
Sergey Eremin
Asked: 2012-06-29 07:06:29 +0800 CST

使用 Nginx 限制对 MVC 应用程序的一个控制器的访问

  • 0

我有一个 MVC 应用程序,其中一个控制器只需要从多个 ips 访问(这个控制器是一个 oauth 令牌回调陷阱 - 对于 google/fb api 令牌)。我的会议看起来像这样:

geo $oauth {
    default 0;
    87.240.156.0/24 1;
    87.240.131.0/24 1;
}

server {
    listen 80;
    server_name some.server.name.tld default_server;
    root /home/user/path;
    index index.php;

    location /oauth {
        deny all;
        if ($oauth) {
            rewrite ^(.*)$ /index.php last;
        }
    }

    location / { 
        if ($request_filename !~ "\.(phtml|html|htm|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|xlsx)$") {
            rewrite ^(.*)$ /index.php last;
            break;
        }
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

}

它有效,但看起来不正确。

以下对我来说似乎合乎逻辑:

    location /oauth {
        allow 87.240.156.0/24;
        deny all;
        rewrite ^(.*)$ /index.php last;
    }

但是这种重写方式一直在发生,允许和拒绝指令被忽略。我不明白为什么...

rewrite nginx mvc
  • 1 个回答
  • 589 Views
Martin Hope
flascuba
Asked: 2010-04-16 11:11:12 +0800 CST

使用 mod_aspdotnet 在 Apache 2.2 上配置 ASP.NET MVC2

  • 3

试图让 Microsoft MVC2 网站在使用 mod_aspdotnet 模块的 Apache 2.2 Web 服务器(在 Windows 上运行)上运行。运行多个 ASP.NET 虚拟主机,尝试添加另一个。MVC2没有默认页面(就像 MVC 的第一个版本有例如 default.aspx)。我尝试了对配置的各种更改:注释掉“DirectoryIndex”,将其更改为“/”。将“ASPNET”设置为“虚拟”,不会加载第一页,总是得到:“403 Forbidden,您无权访问此服务器上的 /。”

以下来自我的 http.conf:

LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo

<IfModule aspdotnet_module> 

 # Mount the ASP.NET /asp application
 #AspNetMount /MyWebSiteName "D:/ApacheNET/MyWebSiteName.com"
 Alias /MyWebSiteName" D:/ApacheNET/MyWebSiteName.com"

 <VirtualHost *:80>
 DocumentRoot "D:/ApacheNET/MyWebSiteName.com"
 ServerName www.MyWebSiteName.com
 ServerAlias MyWebSiteName.com
 AspNetMount / "D:/ApacheNET/MyWebSiteName.com"

# Other directives here
  <Directory "D:/ApacheNET/MyWebSiteName.com">
    Options FollowSymlinks ExecCGI
    AspNet All
   #AspNet Virtual Files Directory
    Order allow,deny
    Allow from all
    DirectoryIndex default.aspx index.aspx index.html
   #default the index page to .htm and .aspx
  </Directory>
 </VirtualHost>

 # For all virtual ASP.NET webs, we need the aspnet_client files
 # to serve the client-side helper scripts.
 AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows /Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"

 <Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
   Options FollowSymlinks
   Order allow,deny
   Allow from all
 </Directory>

</IfModule>

有没有人使用 mod_aspdotnet 模块在 Apache 上成功运行 Microsoft 的 MVC2(或 MVC 的第一个版本)?谢谢 !

apache-2.2 asp.net configuration mvc
  • 2 个回答
  • 9276 Views
Martin Hope
jmucchiello
Asked: 2009-07-26 07:46:07 +0800 CST

如何使所有 URL 都通过一个 PHP 文件运行?

  • 9

url 采用这些形式的 MVC 系统如何通过单个 index.php 文件强制所有请求?

http://www.example.com/foo/bar/baz
http://www.example.com/goo/car/caz/SEO-friendly-name-of-the-object
http://www.example.com/hey/you

编辑:当我尝试下面的重写规则时,我收到此错误:

[error] [client 127.0.0.1] Invalid URI in request GET / HTTP/1.1
[error] [client 127.0.0.1] Invalid URI in request GET /abc HTTP/1.1

编辑:哦,这是/index.php 的完整内容。当我删除重写规则时,它会输出“/”或“/index.php”,否则我会得到 404。

<?php
echo htmlspecialchars($_SERVER['REQUEST_URI']);
?>

已解决:我在重写规则中的 index.php 前面添加了一个 / 然后它起作用了:

再次解决:原来 / 只需要因为我运行的是 2.2.4。当我升级到 2.2.11 时,不再需要 /。

php apache-2.2 mod-rewrite mvc
  • 2 个回答
  • 13379 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve