.htaccess 重定向.html到/

a1o7rhls  于 6个月前  发布在  其他
关注(0)|答案(2)|浏览(72)

我们正在寻找一个解决方案,将我们的.html页面重定向到带有/ so的页面,例如:
旧的:

www.domain.com/url.html

字符串
新增内容:

www.domain.com/url/


我们发现下面的方法来删除.html,这只是不把一个/结束:

RewriteRule ^(.+)\.html$ /$1 [R=301,L]


所以用下面的方法,你删除了.html,但没有一个/放在最后。有没有办法用/替换.html?
希望有人能帮忙

6ljaweal

6ljaweal1#

尝试以下规则,

RewriteEngine On

#redirecting to extension less url with forward slash

RewriteRule ^(.*)\.html$ $1/ [R=301,L]

#handling the extension less url

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1.html [L]

字符串

c86crjj0

c86crjj02#

将此添加到您要重定向的页面:

<meta http-equiv="refresh" content="0; url=http://example.com/" />

字符串

相关问题