我正在使用.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