试图合并两个htaccess的规则集在同一时间:
Trying to combine two htaccess RewriteRules at the same time:
1)把所有非www网址到www 2)将所有请求的index.php
1) transform all non-www URLs to www 2) send all requests to index.php
数2作品与在生产中以下设置:
Number 2 works with the following settings in production:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA]
但与合并
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NC]
的URL表现为应该使用万维网网址时,但有趣地与非www网址使用时
the URLs behave as supposed to when using a www url, but funnily when used with a non-www url.
例如。
http://mydomain.com/customername/admin/signin
成为
http://www.mydomain.com/index.php/admin/signin?/customername/admin/signin
E.g.
http://mydomain.com/customername/admin/signin
becomes
http://www.mydomain.com/index.php/admin/signin?/customername/admin/signin
虽然URL应该仅仅停留在相同的无刷新和参数/客户名称/管理/登入资讯应传递到index.php ...
although the URL should just stay the same without a refresh and the parameters "/customername/admin/signin" should be passed to index.php...
这是我如何能做到这一点有什么建议?我想以后mydomain.com的网址保持不变(因为我的解决方案目前还),但增加了www。盈方的URL。
Any tips on how I can achieve this? I want the URL after mydomain.com to stay the same (as my solution currently does) but add the www. infront of the URL.
它看起来像你只需要添加HTTP_HOST检查的在的杂物箱重写的index.php。
It looks like you just need to add the HTTP_HOST checking before the catch-all rewrite to index.php.
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NC]
这重定向到www的在的任何一个URI已被改写成包罗万象的,则:
This redirects to www before any of the URI have been rewritten to the catch-all, then:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA]
执行包罗万象的,这恰好经过非www得到301重定向到www的域名。
Do the catch-all, which happens after the non-www gets 301 redirected to the www domain.