1
我有一個htaccess文件,應該將用戶指向非www網址。問題是,該網站有點擊時添加到URL末尾的目錄。.htaccess文件添加目錄到URL
例如,subdomain.domain.com會變成subdomain.domain.com/folder/home.html,這很好,但如果再次單擊該鏈接,它將變成subdomain.domain.com/folder/folder/home .html等等。不太好。
下面是.htaccess文件:
RewriteEngine On
RewriteBase/
# Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^subdomain\.domain\.com [NC]
RewriteRule (.*) http://subdomain.domain.com/$1 [R=301,L]
#
# or for the opposite domain.com -> www.domain.com use the following
# DO NOT USE BOTH
#
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} !^www\.sitehere\.com [NC]
#RewriteRule (.*) http://www.sitehere.com/$1 [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# Make sure .htc files are served with the proper MIME type, which is critical
# for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
#AddType text/x-component .htc
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
任何幫助將不勝感激。
謝謝!
也許你會在這裏找到答案:HTTP ://stackoverflow.com/questions/234723/generic-htaccess-redirect-www-to-non-www – bmiljevic 2014-10-30 09:27:44