简体   繁体   English

当不存在斜杠时,mod_rewrite重写规则将重定向浏览器URL

[英]mod_rewrite rewrite rule redirecting browser url when trailing slash is not present

I have a problem with a mod_rewrite rule. 我对mod_rewrite规则有疑问。

basically, I'm trying to hide an ugly folder name. 基本上,我试图隐藏一个难看的文件夹名称。 It works fine if I include a trailing slash, but if I DON'T have the slash, it redirects (is that the proper term, where it actually changes the browser url?) to the ugly folder name. 如果我包含斜杠,它可以正常工作,但是如果我没有斜杠,它将重定向(这是正确的术语,实际上它在哪里更改浏览器的URL?)到丑陋的文件夹名。

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteRule ^AMN/?(.*)$ _map.AMN/index.php?page=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.+)$ /index.php?page=$1 [L]

So basically, if I put in http://example.com/AMN/ with the trailing slash, it works as desired: the browser shows the content in _map.AMN while leaving the pretty url. 因此,基本上,如果我在http://example.com/AMN/后面加上斜杠,则可以按预期工作:浏览器在_map.AMN中显示内容,同时保留漂亮的url。 BUT if I put in http://example.com/AMN without the trailing slash, it redirects the url in the browser to be the undesired http://example.com/_map.AMN 但是,如果我输入http://example.com/AMN时不带斜杠,它会将浏览器中的URL重定向为不需要的http://example.com/_map.AMN

I saw some other questions where it was suggested that the problem would be having a folder named "AMN" in the directory, but this is not the case (at least within this subdomain). 我看到了其他一些问题,有人提出问题可能是目录中有一个名为“ AMN”的文件夹,但事实并非如此(至少在此子域中)。 Here is the question which did NOT do the trick: Another mod_rewrite trailing slash question 这是没有解决问题的问题: 另一个mod_rewrite尾部斜杠问题

Any help is appreciated... 任何帮助表示赞赏...

Lame. 瘸。 Firefox was caching the .htaccess file. Firefox正在缓存.htaccess文件。 My changes weren't even taking place. 我的更改甚至都没有发生。 Works fine in Safari. 在Safari中工作正常。

I thought .htaccess was intended to be read each time... 我以为.htaccess应该每次都被阅读...

not so... 不是...

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

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