简体   繁体   English

htaccess mod_rewrite & apache2 不重写正斜杠

[英]htaccess mod_rewrite & apache2 not rewriting forward slash

In my .htaccess file, a mod_rewrite that I use works on some Apache 2 servers but not on others.在我的 .htaccess 文件中,我使用的 mod_rewrite 适用于某些 Apache 2 服务器,但不适用于其他服务器。 For example, this rewrite works on all Apache2 servers:例如,此重写适用于所有 Apache2 服务器:

RewriteRule ^index-stormwatch.html$ index.php?action=stormwatch 

But when I replace the hyphen with a forward slash in the mod_rewrite like below...但是当我在 mod_rewrite 中用正斜杠替换连字符时,如下所示......

RewriteRule ^index/stormwatch.html$ index.php?action=stormwatch 

...some Apache 2 servers will give me a 404 error (but not all). ...一些 Apache 2 服务器会给我一个 404 错误(但不是全部)。 Is my mod_rewrite improperly written or do I need to edit the httpd.conf file (or another file) so that the forward slash '/' will be accepted by apache?我的 mod_rewrite 是否写得不正确,还是我需要编辑 httpd.conf 文件(或其他文件),以便 apache 接受正斜杠“/”? All mentioned servers are Apache 2/php5.所有提到的服务器都是 Apache 2/php5。

Can you like this:你能喜欢这样吗:

RewriteRule ^index/stormwatch\.html$ /index.php?action=stormwatch [NC,L,QSA]

That should take care of URI /index/stormwatch.html那应该注意URI /index/stormwatch.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM