Articles of mod rewrite

parsing在Apache模式重写获取参数?

我正在使用PHP Fat-Free框架( http://fatfree.sourceforge.net/ )开发一个网站,我需要使用GETvariables,但他们不会parsing,因为我使用Mod重写。 这是我的.htaccess文件的当前状态: # Enable rewrite engine and route requests to framework RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php [L,QSA] 目前,我可以通过去www.domain.com/mypage请求框架页面,但我需要使用诸如www.domain.com/mypage?variable=xyz 无论如何,我可以去做这件事吗? 提前致谢! 编辑: 我使用了3级的重写日志,并要求www.domain.com/?x=1,这是日志中的内容: ::1 – – [21/Aug/2010:21:09:28 +1200] [localhost/sid#1545150][rid#2054260/initial] (3) [perdir D:/Development/xampplite/htdocs/] strip per-dir prefix: D:/Development/xampplite/htdocs/ -> ::1 – – [21/Aug/2010:21:09:28 +1200] […]

什么是相当于这个mod_rewrite规则的nginx?

我的WordPress的是告诉我更新我的htaccess文件: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 我使用nginx,我有这个,但它不工作: location / { root /home/mywebsite/public; index index.php index.html index.htm; if (!-e $request_filename) { rewrite ~(.+)$ /index.php?q=$1 last; } }

如何在Apache2中像tomcat中那样部署两个基于zend框架的应用程序

我有两个叫做finance和fleet Zend框架应用程序。 它们都具有相同的.htaccess文件,如下所示 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ – [NC,L] RewriteRule ^.*$ index.php [NC,L] 我创build了两个名为fleet.local和finance.local虚拟主机。 这是我的fleet.local文件: # APACHE CONFIGURATION FOR THE fleet.local APPLICATION <VirtualHost *:80> ServerName fleet.local DocumentRoot /home/user/fleet/public SetEnv APPLICATION_ENV dev <Directory /home/user/fleet/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all […]

如何使用mod_rewriteredirect包含多个查询string的多个特定的URL?

我们最近将一个网站从一个自定义CMS迁移到了drupal。 为了保留用户collections的某些链接(我们有大约120次redirect),我们希望将原始url转发到新的url。 我一直在寻找几天,但似乎无法find任何我所需要的简单。 我们有现有的URLs包含一个或多个查询string,例如: /article.php?issue_id=12&article_id=275 我们想转到新的位置: http://foobar.edu/content/super-happy-fun-article 我开始使用: RewriteEngine On RewriteRule ^ / article \ .php?issue_id = 12&article_id = 275 $ http://foobar.edu/content/super-happy-fun-article [R = 301,L] 但是,这不起作用。 一个简单的RewriteRule工程: RewriteRule ^ test \ .php $ index.php 目前还不清楚我需要如何使用{QUERY_STRING} 基本上,它是从一个现有的URL到一个新的120个简单的redirect。 我不需要范围[0-9],因为现有的URL没有顺序。 也许我可以用RewriteMap和一个简单的文本文件来完成我所需要的工作: index.php?issue_id = 12&articleType_section = 0&articleType_id = 65 http://foobar.edu/category/fall-2008 如果任何人有任何想法使用mod_rewrite来实现这一点,或者如果有一个更好的,或更简单的国防部,我也打开。 谢谢!

Apache问号重写规则的问题

所以我正在尝试redirect index.php?action=search&query=search text goes here 至 search?query=search text goes here 我试过这个,但没有运气 RewriteRule ^search/? index.php?action=search&query=$1 [QSA,L] 编辑:解决scheme是 RewriteCond %{QUERY_STRING} ^query=(.*)$ RewriteRule ^search/? index.php?action=search&query=%1 [QSA,L] 因为我在我的htaccess中有一些其他的RewriteRules,我必须把它们放在它们上面。 我的其他rewriterules是这样的: RewriteRule ^(\w+)/?$ index.php?action=$1

如果省略了最后一个斜杠,则重写更改的URL

我有重写规则工作正常,但最终如果在去index.php时省略了尾部斜线,则更改可见的URL: RewriteEngine on RewriteCond %{REQUEST_URI} !main RewriteRule /.* /~user/main$0 当有人访问 http://user.dev.example.com/utilities/pib/ 该页面正常工作。 但是,如果他们访问 http://user.dev.example.com/utilities/pib 他们被redirect到 http://user.dev.example.com/~user/main/utilities/pib/ 这仍然可以正常工作,但我宁愿让url不要改变。 服务器有其他configuration,允许~user将您带到光盘上的public_html (这些文件所在的位置)。 所以实际的URL应该是: http://dev.example.com/~user/main/utilities/pib/ 但它仍然留下了我的名字在领域。 我不确定我是否能够解决这个问题,但是我也不确定其他configuration可能导致这个问题。

Apache重写Mod

我正在尝试实现虚拟子域,因为我的托pipe服务提供商已经设置了我可以拥有的子域数量的限制! 我已经有一个通配符的DNS条目,所以所有子域都被接受并发送到我的域的根目录。 这是我已经把.htaccess处理redirect: RewriteEngine on RewriteCond %{HTTP_HOST} !^(www|admin).* [NC] RewriteCond %{HTTP_HOST} ^([a-zA-Z0-9]+)\.domain\.-com RewriteCond /home/username/public_html/subdomain/%1 -d RewriteRule ^(.*) /home/username/public_html/subdomain/%1/$1 问题是在实际redirect的最后一行,服务器显示500(内部服务器错误),但Apache错误日志不会扩大错误。 如果我把这样的东西放在它的位置: RewriteRule ^(.*) index.php?path=/home/username/public_html/subdomain/%1/$1 它工作正常…而path是正确的文件path。

configurationApache重写提供主页的根,其余的网站是在subdir?

由于遗留的原因,我有一个主要生活在一个子目录中的wordpress网站: http : //www.zmxmusic.com/site 。 不过,它也在http://www.zmxmusic.com上提供主页。 我没有访问当前使用的Apacheconfiguration,我很难在新的服务器上复制这种行为。 wordpress网站位于/ srv / zmx / wp / site的文件系统中,wordpress的主页和siteurl被定义为http://www.zmxmusic.com/site 。 我有这在Apacheconfiguration: <VirtualHost *:80> ServerName www.zmxmusic.com ServerAlias …omitted… DocumentRoot /srv/zmx/wp <Directory /srv/zmx/wp> Options FollowSymLinks AllowOverride FileInfo Options Order allow,deny Allow from all </Directory> LogLevel info ErrorLog /var/log/apache2/zmx_app-error.log CustomLog /var/log/apache2/zmx_app-access.log combined RewriteEngine On Options +FollowSymlinks RewriteCond %{REQUEST_URI} !^/(site/|index\.php) RewriteCond %{SCRIPT_FILENAME} !-f […]

Apache使用Rails Asset Pipeline生成的资产提供空的gzip

我遵循博文“资产pipe道”中描述的步骤,从开发到生产,并将其调整到我的环境中。 这两个重要的文件是: /etc/apache/site-available/example.com <VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot "/var/www/sites/example.com/current/public" ErrorLog "/var/log/apache2/example.com-error_log" CustomLog "/var/log/apache2/example.com-access_log" common <Directory "/var/www/sites/example.com/current/public"> Options All AllowOverride All Order allow,deny Allow from all </Directory> <Directory "/var/www/sites/example.com/current/public/assets"> AllowOverride All </Directory> <LocationMatch "^/assets/.*$"> Header unset Last-Modified Header unset ETag FileETag none ExpiresActive On ExpiresDefault "access plus 1 year" </LocationMatch> RewriteEngine On # Remove […]

在调用Silex之前,在URL中添加一个尾部的斜线

作为大多数框架,Silex依赖于重写规则来处理漂亮的URL。 build议使用此框架的默认.htaccess RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [QSA,L] 这是直接的,工作得很好。 但是,如果我也想重写请求uri始终包含一个结尾的斜杠我不能得到它的工作。 我曾尝试过使用以下规则。 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^(.*)/$ RewriteRule . %{REQUEST_URI}/ [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [QSA,L] 为了debugging这个,我尝试了使用[R]标志强制redirect,我可以看到它的正确评估,但是这两个规则在一起并没有这样做,因为结果请求uri仍然没有结尾的斜杠。 总结一下: example.com/foo应该redirect到example.com/foo/ ,最后由index.php处理。 example.com/foo/应该由index.php处理而不做修改。 我不是mod_rewrite的专家,但是我在这里花了一段时间阅读文档,我有一种直觉,认为这应该可以通过这种方式来解决。 在此先感谢,亚历克斯