开发者

trailing slash gives internal server error

I want all my pages to work if the user added a trailing slash in 开发者_运维问答the end or not

the following line works

RewriteRule ^index/page/([0-9]+)/?$ /cmstut/index.php?page=$1 [QSA,L]

but the the following line cause an internal server error, It's the last line That's the line that should rewrite all other pages which have no attributes like the contact page, about us page or index page

RewriteRule ^(.+[^/])/?$ /cmstut/$1.php [QSA,L]


You should better use just one spelling (with or without trailing slash) and redirect if the requested URI path is incorrect:

# add trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]

# remove trailing slash
RewriteRule (.+)/$ /$1 [L,R=301]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜