始终重定向到index.php

问题描述 投票:1回答:1

我正在尝试将站点重定位到临时文件夹,以便在根目录中安装CMS。重定向工作,但站点中的所有内部链接现在将我带回临时文件夹中的索引页面。根目录中的.htaccess如下:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/old/ [R=301,NC]
php html .htaccess
1个回答
1
投票

这是因为你将所有内容重定向到新网址。你应该这样做:

RewriteRule ^$ http://www.example.com/old [R=301,NC]
RewriteRule ^(.*)$ http://www.example.com/old/$1 [R=301,NC]

PS:$ 1接受表达式中的参数

PS2:您不应该使用代码301进行临时重定向,302更适合https://en.wikipedia.org/wiki/HTTP_302

© www.soinside.com 2019 - 2024. All rights reserved.