1
我對.htaccess編輯或正則表達式幾乎一無所知。我做了什麼,試圖讓我的網站重新定向從www
版本non-www
版本是我跟着張貼在這裏的答案:.htaccess將www重定向到非www無法正常工作
不過,我得到的是,如果我進入www.example.com
,我得到:
example.com/example.com/
和我的網站上
404錯誤這是我的.htaccess文件:
#Adjust default time zone
SetEnv TZ America/Toronto
#Begin redirect www to non-www
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule^http://%1%{REQUEST_URI} [NE,R=301,L]
# Google Analytics Integration - Added by cPanel.
<IfModule mod_substitute.c>
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|(<script src='/google_analytics_auto.js'></script>)?</head>|<script src='/google_analytics_auto.js'></script></head>|i"
</IfModule>
# END Google Analytics Integration
有人能告訴我我做錯了什麼嗎?
你是如何在重定向的URL中獲得example.com/example.com /'的?您是否嘗試清除瀏覽器緩存? – anubhava
配置文件或.htaccess中必須有其他內容。或者,也許該網站在一個子目錄中,並且目錄前綴存在一些問題。 –