我目前设置了htaccess文件,以便在有人输入www.example.co.uk/index.php
时重定向到www.example.co.uk/
但是,如果有人输入www.example.co.uk/index
,则网址会保持为www.example.co.uk/index
有没有办法可以将其重定向到根并隐藏/index
部分?
htaccess代码目前如下(我遗漏了大部分301重定向)
ErrorDocument 404 /notfound.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.w-co\.co.uk$
RewriteRule (.*) http://www.w-co.co.uk/$1 [R=301,L]
Options +FollowSymLinks
# Redirect index in any directory to root of that directory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.[^\ ]*\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(php|html?)$ http://www.w-co.co.uk/$1? [R=301,L]
AddType video/mp4 .mp4
AddType video/ogg .ogv
AddType video/webm .webm
Redirect 301 /%20built-up-lettering.php http://www.w-co.co.uk/built-up-lettering.php
Redirect 301 /">light http://www.w-co.co.uk/light_boxes.php
答案 0 :(得分:0)
为您的.htaccess
添加重写规则:
^www.example.co.uk/index$
这应该涵盖它。