我正在使用.htaccess创建Google风格的SEO规则,并且我遇到了最后部分的问题。使用.htaccess创建Google风格的网址
如果键入google.com/nexus到浏览器,你会被重定向到www.google.com/nexus/
它增加了WWW以及结尾的斜线。
我该如何用.htaccess实现这个功能?
#Start rewrite engine
RewriteEngine on
RewriteBase/
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|dev|d10|m)\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Hide the private directory by redirecting the request to index.php
RewriteRule ^(private|\.git) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
如果您发现任何需要提高速度/可伸缩性的地方,我们将不胜感激。
我的最终解决方案:
RewriteEngine on
RewriteBase/
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|dev|d10|m)\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Add Trailing Slash
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
# Hide the private directory by redirecting the request to index.php
RewriteRule ^(private|\.git) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
*谷歌风格的URL * ...这一定是一个技术术语? – rdlowrey