开发者

.htaccess - URL Regex - never ending loop issue?

I posted up a question about an hour ago asking a regex question about trailing slashes

(http://stackoverflow.com/questions/4907130/url-regex-remove-trailing-slash-from-file-name-and-end-of-url)

And a very helpful person gave me this to redirect pages with a trailing slash to a page with none.

However I have just noticed that it causes an infinite (never ending loop) of redirects if you try and access a folder, as you go to say http://example.com/images the server (Apache) adds a trailing slash as its a directory, then the Regex removes the slash, redirects back to 开发者_如何学Cthe http://example.com/images URL which then gets its slash added back on by Apache etc etc :/

Any Ideas as to how to modify the rule below to prevent this?

 RewriteRule ^(.*)/$    $1  [R=301]

Many thanks, help always appreciated! :)


Try this:-

RewriteRule ^(.*)/$    $1  [R,L]


Added in the line below just above my current RewriteRule ^(.*)/$ $1 [R=301] rule

RewriteCond %{REQUEST_FILENAME} !-d

Thanks for the reply though limc :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜