首先,我是这个网站的新手并想表示感谢,因为我已经通过点击此处发布的指南解决了2个问题
谢谢!
我似乎无法找到答案的唯一问题是:
由于seo建议,我现在需要添加一个" /"到我的网站的末尾url使用.htaccess如果pos在apache服务器上
我正在使用.htaccess
重定向非www。网址到www。网址
从网址末尾删除.html
我当前.htaccess的副本
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
感谢阅读和给予任何帮助!!
答案 0 :(得分:0)
试试这个,
#first add www to non-www adding backslash
RewriteEngine on
RewriteCond {HTTP_HOST} !^www
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
#rewrite html extension (remove)
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html