开发者

mod_rewrite infinite loop problem

开发者 https://www.devze.com 2022-12-27 07:46 出处:网络
I\'ve been trying to do the following with mod_rewrite on the server there is a file about.htm (which is found in the root directory of the domain)

I've been trying to do the following with mod_rewrite

  1. on the server there is a file about.htm (which is found in the root directory of the domain)
  2. I need to redirect about.htm to about/
  3. On the server still keep about.htm, hence when about/ is called, it actually loads up about.htm

I tried something like this:

RewriteRule ^about/$       about.htm [L]
RewriteRule ^about\.htm$   about/    [R=302]

I also tried changing it a bit and see what happends, but I always end 开发者_如何学Goup with an infinite loop of redirection or a 500 server error.

Any idea why it's not working as intended?

Thanks in advance!


You need to test the path in the request line:

RewriteRule ^about/$       about.htm [L]
RewriteCond %{THE_REQUEST} ^GET\ /about\.htm
RewriteRule ^about\.htm$   about/    [R=302]


Only this line should do the work.

RewriteRule ^about\.htm$   http://yourdomain.com/about/    [R=302]
0

精彩评论

暂无评论...
验证码 换一张
取 消