2
我知道有很多關於非www重定向到www域的信息。但我的問題是,我可以管理主頁的重定向,但不是子頁面。將所有頁面從非www重定向到htaccess中的www
你可以看到的例子here所以,當我輸入網址像ourenglishclass.eu/fill-in-text-5th-6th-grade重定向發生了www.ourenglishclass.eu/index.php
我可以看到,有可能是更多的重寫規則,這使得它這樣的行爲,但我不能找到什麼,或者如何解決這個
這些都是重定向規則的index.php
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
我試過這些重定向規則, WWW到www:
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
和(這是因爲我的測試也以https)
# Redirect to www
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
希望有人能指出
非常感謝您的解答和解決方案!這樣可行! –