我的网址重写工作正常,唯一的一点是,点击 HOME 返回后,网址显示为mywebsite.com/test/index
,我想摆脱只显示的索引mywebsite.com/test/
。这是我的.htaccess:
RewriteEngine On
RewriteBase /rscares/
RewriteCond %{THE_REQUEST} \s/+(rscares/.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]
有任何帮助吗?感谢。
答案 0 :(得分:1)
您可以使用此代码:
RewriteEngine On
RewriteBase /rscares/
RewriteCond %{THE_REQUEST} \s/+(rscares)/(?:index)?(.*?)\.html[\s?] [NC]
RewriteRule ^ /%1/%2 [R=301,L,NE]
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]