我正在尝试使用以下Redirect命令将我的整个站点重定向到根目录中的子文件夹。
Redirect 301 / http://example.com/folder/
但是,当我打开网站时,它会被重定向到http://www.example.com/folder/folder/folder/folder/folder/folder/folder...
我在这里做错了吗?
I am trying to redirect my entire site to a subfolder present in the root directory using the following Redirect command.
Redirect 301 / http://example.com/folder/
However, when I open the website, it gets redirected to something like http://www.example.com/folder/folder/folder/folder/folder/folder/folder...
Am I doing something wrong here?
最满意答案
是的,你正在重定向以/开头的任何东西,当然包括/folder/它只是保持重定向。 在不排除该部分的情况下,您无法将整个网站重定向到自身的一部分。
改为使用它:
RewriteEngine on RewriteCond %{REQUEST_URI} !^/folder/ RewriteRule ^(.*)$ /folder/$1 [NE,R=301,L]它将重定向不在/folder/任何内容。
要仅重定向主页,请改用:
RewriteEngine on RewriteRule ^$ /folder/ [R=301,L]Yes, you're redirecting anything starting with / so of course that includes /folder/ and it just keeps redirecting. You can't redirect your whole site to a part of itself without excluding that part.
Use this instead:
RewriteEngine on RewriteCond %{REQUEST_URI} !^/folder/ RewriteRule ^(.*)$ /folder/$1 [NE,R=301,L]It will redirect anything that is not in /folder/.
To only redirect the homepage, use this instead:
RewriteEngine on RewriteRule ^$ /folder/ [R=301,L]更多推荐
Redirect,folder,http,电脑培训,计算机培训,IT培训"/> <meta name="descript
发布评论