2014-06-17 28 views
0

如何重定向我的www.example.com/index.html文件www.example.com/index使用.htacces如何重定向我的www.example.com/index.html文件www.example.com/index

,如果我的網址是像www.example.com/test1/index.htm 或 ww.example.com/test/test2/index.htm

如何重定向頁面帶外擴展

# Redirect everyone but for me 
RewriteEngine On 
RewriteBase/
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1 
RewriteRule .* http://www.example.com [R=302,L] 

上面的代碼我在網上找到,但它不工作...指定如何.htacces規則

回答

0

可以在根.htaccess使用這些規則:

RewriteEngine On 

RewriteCond %{THE_REQUEST} \s/+(.*?)\.html[\s?] [NC] 
RewriteRule^/%1 [R=301,L,NE] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{DOCUMENT_ROOT}/$1\.html -f [NC] 
RewriteRule ^(.+?)/?$ /$1.html [L]