我正在从Apache切换到Nginx / fcgi,而且在尝试设置应用程序重写规则时遇到小问题。 代码通过使用PATH_INFO来处理路由,例如example.com/foo/bar/将被路由到example.com/index.php/foo/bar/ 我已经修改了服务器configuration来传递PATH_INFO: location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param SCRIPT_FILENAME /var/www/public$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; } 而重写处理程序: location / { root /var/www/public; index index.html index.htm index.php; if (!-f $request_filename) { rewrite ^(.*)/(.*)$ /index.php/$2 break; } } 有了' rewrite_log on ',这个url看起来是正确的路由: [error]: *2 open() "/var/www/public/index.php/test" […]
我给了一个新的网站设置或重新编写规则。 我从来没有使用过他们,我试图了解我们在这里做什么 RewriteEngine on RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.myco\.com RewriteRule (.*) http://www.myco.com/$1 [R=301,L] RewriteCond $1 !^(CCSFG|images|fonts|themes|robots\.txt|index\.php) [NC] RewriteRule ^(.*)$ /index.php/$1 [L] 如果我明白这一点,第一个规则集 RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.myco\.com RewriteRule (.*) http://www.myco.com/$1 [R=301,L] 说: 如果HTTP_HOST是任何东西 如果HTTP_HOST不是以www.myco.com开头的话 然后 重写任何页面请求开始http://www.myco.com/ ,返回301redirect,并停止处理更多的规则 下一个规则集 RewriteCond $1 !^(CCSFG|images|fonts|ee-system|themes|robots\.txt|index\.php) [NC] RewriteRule ^(.*)$ /index.php/$1 [L] 说:如果请求不是以CCSFG,图像或字体或等(不区分大小写)开始,那么重写整个请求以预先添加/index.php/并停止处理更多的规则 我的解释是否正确? 如果是这样,第二个规则集的目的是什么? 为什么我要将/index.php/添加到这些条目中?
我想在一个文件夹里面设置一个初始页面,除了常见的index.htm外 我想将index.htm更改为/folder/file.htm 是否有可能使用nginx? 在我的Apache服务器,我所要做的就是configurationhtaccess文件,把这个:DirectoryIndex /folder/file.htm PS:我试图用RegEx来做到这一点,但我确实喜欢DirectoryIndex 非常感谢!
我已经设置了一个虚拟主机,它指定了一个默认的文件加载URL时调用。 我遇到的问题是我需要默认的DirectoryIndex文件出现在URL中。 所以当我去www.mysite.co.uk时,我想让www.mysite.co.uk/app.php出现在URL中。 我如何使用我的apache.conf文件中的虚拟主机configuration来实现这个function? 这是我现在的代码: <VirtualHost *:80> ServerName *.mysite.co.uk DocumentRoot "/var/www/html/mysite/web/" DirectoryIndex app.php </VirtualHost>
我想redirecthttp://abc.xyz.ac.uk/folders/abc/lmn http://abc.xyz.ac.uk/folders/abc/lmn.html 这里是我启用这个代码 <Directory /var/www/folders> RewriteEngine on RewriteRule ^/abc/lmn$ ^/abc/lmn.html [NC,L] Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> 这条规则有什么问题,这是否包含重写的正确位置? 谢谢
我试图build立一个nginxconfiguration如下:当收到像/tile/SteveCountryVic/1/2/3.png的请求: 尝试将其传递给http://localhost:5005/1/2/3.png 如果那404s,传递给另一台服务器作为/tile/SteveCountryVic/1/2/3.png 这是我的configuration,这是不是很工作: server { listen 80; server_name localhost; error_log /tmp/nginx.error.log notice; access_log /tmp/nginx.access.log; location /tile/SteveCountryVic/ { rewrite_log on; #rewrite ^.*/(\d+)/(\d+)/(\d+).*$ /$1/$2/$3.png break; proxy_intercept_errors on; error_page 404 = @dynamiccycletour; #proxy_set_header Host $http_host; #proxy_pass http://127.0.0.1:5005; proxy_redirect /tile/SteveCountryVic/ http://localhost:5005/; location @dynamiccycletour { rewrite_log on; #rewrite ^(\d+)/(\d+)/(\d+).*$ /tile/SteveCountryVic/$1/$2/$3.png break; proxy_pass http://115.xxx:20008; } location /tile/ { proxy_set_header Host […]
试图弄清楚这一点非常困难。 我已经把我的网站从另一个平台更改为Joomla,现在Nginx无法处理旧的url。 我的老url是这样的: example.com/home.php example.com/contact-us.php 我的新Joomla SEF的Url是这样的: example.com/home example.com/contact-us 根据Joomla指南,我有以下的Nginxconfiguration: location / { try_files $uri $uri/ /index.php?$args; } # Process PHP location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } 我想让Nginx把这些旧的URL传给Joomla来处理它。 现在发生的事情是,Nginx将这些旧的url作为php文件处理,然后向我展示这个No input file specified. 错误。 然后,我改变了PHP块内的try_files为try_files $uri /index.php?$args; 所以我的Nginxconfiguration如下所示: location / { try_files $uri […]
我已经看了网上的其他几十个问题和参考 – 而且通过我所有的计算,我的设置应该可以工作,但是不能。 我有php-fpm的nginx安装。 如果我尝试访问一个.php文件,它运行正确,我得到正确的结果。 我在我的configuration文件中得到这个: location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } 现在,我想设置我的networking应用程序,以便/somedir/file自动执行/somdir/file.php同时仍然在浏览器的地址栏中显示/somdir/file 。 所以我修改我的configuration来包含以下内容: location / { try_files $uri $uri/ $uri.php?query_string } 这种工作,也就是服务器访问.php文件。 然而,不是使用上面现有location ~ \.php$块来执行它,而只是将php源代码作为下载到浏览器中。 如果我手动追加.php到所请求的URL,那么PHP被执行。 感觉就好像服务器把try_files和$uri.php匹配$uri.php ,然后就不会在位置做另一个传递来看看它需要做什么。 我试图把php块放在location /上面和下面,但是没有什么区别。 我怎样才能得到执行的PHP?
我需要创build一个RewriteRule来将像/tdg/image.jpg?mode=crop&width=300&height=300这样的URLpath/tdg/image.jpg?mode=crop&width=300&height=300给本地代理。 代理需要将给定的URL转换为以下格式。 http://localhost:8888/unsafe/300×300/smart/tdg/image.jpg 我先尝试使用ProxyPassMatch apache指令,但是我无法从查询string中检索宽度和高度数据。 ProxyRequests On ProxyPreserveHost On ProxyPassMatch ^\/(tdg.+\.(?:png|jpeg|jpg|gif))\?mode=crop.+width=(d+)&height=(d+) http://localhost:8888/unsafe/$2x$3/smart/$1 我也试过RewriteRule RewriteEngine On RewriteRule ^\/(tdg.+\.(?:png|jpeg|jpg|gif))\?mode=crop.+width=(d+)&height=(d+) http://localhost:8888/unsafe/$2x$3/smart/$1 在这两种情况下,代理的结果URL都是http://localhost:8888/unsafe/x/smart/$1 ,其中应该是http://localhost:8888/unsafe/300×300/smart/tdg/image.jpg 我不知道为什么我不能使用group正则expression式从查询string中获取width和height值。
我的网站根目录中有一个.htaccess,如下所示: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.mydomain\.pl [NC] RewriteCond %{HTTP_HOST} ^(?:www\.)?([a-z0-9_-]+)\.mydomain\.pl [NC] RewriteRule ^/?$ /index.php?run=places/%1 [L,QSA] RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{REQUEST_URI} !^/images/ RewriteCond %{REQUEST_URI} !^/upload/ RewriteCond %{REQUEST_URI} !^/javascript/ RewriteRule ^(.*)$ /index.php?runit=$1 [L,QSA] 我已经在文件夹客人安装了自定义留言簿,现在我想要禁用上面这个特定文件夹的规则。 所以当我input: mydomain.pl/guests 我想正常去实际文件夹的客人。 我知道我需要以某种方式禁用客人子文件夹上面的规则,但我该怎么做?