【发布时间】:2012-02-03 09:54:38
【问题描述】:
我有以下重写规则:
#remove the www.
RewriteCond %{HTTP_HOST} ^www.website.co.uk$ [NC]
RewriteRule ^(.*)$ http://local.website.co.uk/$1 [R=301,L]
#this removes php extention
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# stops you accessing url with.php
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^.?\ ]+)\.php
RewriteRule ^([^.]+)\.php(/.+)?$ /$1%{PATH_INFO} [R=301]
我想添加一条规则,如果有人尝试使用斜杠访问网站,则删除尾部斜杠。
例如
website.co.uk/cheese/ 应该重定向到 /cheese
如您所见,我有一个规则,它使用 .php 扩展名重定向 ursl,不知道从哪里开始。
我确实在根文件夹中有目录,我不希望删除尾随 url,但我可以为它们添加忽略规则。
干杯
【问题讨论】:
标签: apache .htaccess mod-rewrite trailing-slash