Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如:
mydomain.com/whatever
表现得像
MyDomain.com/whatever
我可以在 htaccess 中使用重写规则吗?
我试过了:
RewriteCond %{HTTP_HOST} !^www\.mrhowtosay\.com/([^&\s]+) RewriteRule ^(.*)$ http://www\.MrHowToSay.com/$1 [R=301,L]
但它无限循环
该%{HTTP_HOST}变量只是通过“Host:”请求头提交的主机名。它不包含任何 URI 路径信息。因此,该/([^&\s]+)位将导致条件保证失败(否定始终为“真”)。尝试:
%{HTTP_HOST}
/([^&\s]+)
RewriteCond %{HTTP_HOST} !^www\.MrHowToSay\.com$ RewriteRule ^(.*)$ http://www.MrHowToSay.com/$1 [R=301,L]