【发布时间】:2013-10-07 07:33:21
【问题描述】:
我想从旧文件夹重定向到新文件夹。
我想将http://domain.com/old/* 网址重定向到http://domain.com/new/*。
我发现了一个问题:Redirect folder to another with htaccess
我尝试在文档根目录中编写一个 .htaccess,仅在上述问题的答案中给出以下代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^/old/(.*)$ /new/$1 [L,NC,R=302]
我还在 httpd.conf 文件中启用了 mod_rewrite。但我仍然无法让 apache 从旧文件夹重定向到新文件夹。
我还检查了 apache 错误日志,我得到的只是以下错误:
[error] [client x.x.x.x] File does not exist: <documentroot>/old
【问题讨论】:
-
^/old/(.*)$应该是^old/(.*)$ -
@hjpotter92 我试过了,但仍然遇到同样的错误
-
@hjpotter92:重写指令不起作用,因为 AllowOverwrite 指令设置为无。设置为All,使指令生效。
标签: apache .htaccess mod-rewrite