清洁所有阶段 url
clean at all stages url
问题是斜线 /
“example.ru/aboutus/
” 转换为“500 服务器错误” 并在末尾附加 http://example.ru/aboutus/.html
uri.
.HTACCESS
## www.site/index.html ==> site/index.html ##
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ / [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
## index.html ==> index ##
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ .html
## index/ ==> index ##
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ [L,R=301]
但是输入斜杠,我掉进了500页错误
HTML
in the html code pages do not have any links .html extension
`<a href=aboutus>About Us</a>` except `<a href=index.html>index</a>`
问题
- (对吗?)
- (html 中的规范有帮助吗?)
- (是否要禁止 Robots.txt * .html?)
如何解决没有重复的问题,使所有页面都没有斜杠和扩展名。html? seo
所需的一切
找到解决方案
Options All -ExecCGI -Multiviews -Indexes -Includes +FollowSymLinks
# This tag ensures the rewrite module is loaded
<IfModule mod_rewrite.c>
# enable the rewrite engine
RewriteEngine On
# Set your root directory
RewriteBase /
# remove the www extension
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ / [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
# remove the .html extension
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
RewriteRule (.*)\.html$ [R=301]
# remove index and reference the directory
RewriteRule (.*)/index$ / [R=301]
# remove trailing slash if not a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ [R=301]
# forward request to html file, **but don't redirect (bot friendly)**
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) \.html [L]
</IfModule>
问题是斜线 /
“example.ru/aboutus/
” 转换为“500 服务器错误” 并在末尾附加 http://example.ru/aboutus/.html
uri.
.HTACCESS
## www.site/index.html ==> site/index.html ##
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ / [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
## index.html ==> index ##
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ .html
## index/ ==> index ##
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ [L,R=301]
但是输入斜杠,我掉进了500页错误
HTML
in the html code pages do not have any links .html extension
`<a href=aboutus>About Us</a>` except `<a href=index.html>index</a>`
问题
- (对吗?)
- (html 中的规范有帮助吗?)
- (是否要禁止 Robots.txt * .html?)
如何解决没有重复的问题,使所有页面都没有斜杠和扩展名。html? seo
所需的一切找到解决方案
Options All -ExecCGI -Multiviews -Indexes -Includes +FollowSymLinks
# This tag ensures the rewrite module is loaded
<IfModule mod_rewrite.c>
# enable the rewrite engine
RewriteEngine On
# Set your root directory
RewriteBase /
# remove the www extension
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ / [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
# remove the .html extension
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.html\ HTTP
RewriteRule (.*)\.html$ [R=301]
# remove index and reference the directory
RewriteRule (.*)/index$ / [R=301]
# remove trailing slash if not a directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ [R=301]
# forward request to html file, **but don't redirect (bot friendly)**
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) \.html [L]
</IfModule>