【发布时间】:2014-12-26 00:02:18
【问题描述】:
我有一个 htaccess 文件,它应该将用户定向到非 www URL。问题是,该站点的目录在单击时会添加到 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>
任何帮助将不胜感激。
谢谢!
【问题讨论】:
-
也许你会在这里找到答案:stackoverflow.com/questions/234723/…
标签: .htaccess friendly-url modx