Php 使用.htaccess创建谷歌风格的URL
我正在用.htaccess创建谷歌风格的搜索引擎优化规则,最后一部分我遇到了问题 如果您在浏览器中键入google.com/nexus,您将被重定向到www.google.com/nexus/ 它添加了www以及尾部斜杠 如何使用.htaccess实现这一点Php 使用.htaccess创建谷歌风格的URL,php,.htaccess,Php,.htaccess,我正在用.htaccess创建谷歌风格的搜索引擎优化规则,最后一部分我遇到了问题 如果您在浏览器中键入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
#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]
将example.com替换为您的域
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
将example.com替换为您的域
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
领先www
领先www
谷歌风格的URL。。。这一定是个技术术语?谷歌风格的URL。。。那一定是个专业术语吧?