我遇到了Apache的问题,不想读取我的重写指令,并根据这些指令重写我的URL。 我有条件和规则直接写入我的Apache httpd.conf文件中:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_URI} Round_2 RewriteRule ^Round_2/(.*)$ /newBuyer/desktop/$1 [R=301,L] RewriteCond %{REQUEST_URI} itemList RewriteRule ^/?(.*)/itemList/(.*)$ /newBuyer/$1/search/$2 [R=301,L] RewriteCond %{REQUEST_URI} eventDetail RewriteRule ^/?(.*)/eventDetail/(.*)$ /newBuyer/$1/event/$2 [R=301,L] </IfModule>
我已经重新加载Apache使用:
$ apachectl -k graceful
刷新浏览器caching,redirect不起作用。 我能够使它在我的本地Windows Apache实例上工作,但不能在我的Apache的Cent7实例上工作。
我已经确认重写mod已经加载。
在条件和规则之间的IfModule之后添加目录标记之后,我可以使URL重写工作。 这是最后的工作结果:
<IfModule mod_rewrite.c> <Directory "/directory/to/designers/files/"> RewriteEngine On RewriteCond %{REQUEST_URI} Round_2 RewriteRule ^Round_2/(.*)$ /newBuyer/desktop/$1 [R=301,L] RewriteCond %{REQUEST_URI} itemList RewriteRule ^/?(.*)/itemList/(.*)$ /newBuyer/$1/search/$2 [R=301,L] RewriteCond %{REQUEST_URI} eventDetail RewriteRule ^/?(.*)/eventDetail/(.*)$ /newBuyer/$1/event/$2 [R=301,L] </Directory> </IfModule>
谢谢