【发布时间】:2013-12-08 08:57:56
【问题描述】:
我有一个奇怪的问题
我将代码添加到 htaccess 文件以将任何非 www 重定向到 www。但现在它把我带到了网站文件所在的子目录
从 DNS cpanel 我已将域目录指向 /main_web
当我现在输入 throughtheglasseye.org 时,它需要 hxxp://www.throughtheglasseye.org/Main_web/ 并出现错误 404 页面未找到
这是我的代码 -
# Redirect non-www to www:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
# Disable htaccess view:
<Files .htaccess>
order allow,deny
deny from all
# Disable directory browsing:
</Files>
IndexIgnore *
我不确定这是否正确,请检查并让我知道我能做些什么来解决这个问题
提前非常感谢
【问题讨论】:
标签: apache .htaccess mod-rewrite redirect web