Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何将某事物/任何事物重定向到某事物新事物/任何事物_.htaccess_Redirect - Fatal编程技术网

.htaccess 如何将某事物/任何事物重定向到某事物新事物/任何事物

.htaccess 如何将某事物/任何事物重定向到某事物新事物/任何事物,.htaccess,redirect,.htaccess,Redirect,我正在尝试重定向URL,如下所示 www.mydomain.com/about/anything=>www.mydomain.com/aboutme/anything (两个URL中的任何部分都应相同) 我试过遵守规则,但效果不好 RewriteRule ^/about(/?)?$ http://www.mydomain.com/aboutme/$1 [R=300, L] 及 有什么帮助吗 谢谢..您应该为此使用301重定向 Redirect 301 /about/ http://www.m

我正在尝试重定向URL,如下所示

www.mydomain.com/about/anything=>www.mydomain.com/aboutme/anything (两个URL中的任何部分都应相同)

我试过遵守规则,但效果不好

 RewriteRule ^/about(/?)?$ http://www.mydomain.com/aboutme/$1 [R=300, L]

有什么帮助吗
谢谢..

您应该为此使用301重定向

Redirect 301 /about/ http://www.mydomain.com/aboutme/

您应该为此使用301重定向

Redirect 301 /about/ http://www.mydomain.com/aboutme/

由于您使用的是
.htaccess
,因此不会尝试匹配前面的
/
。如您的示例所示,使用
mod_rewrite
,您应该能够使用:

RewriteRule ^about/(.*)$ aboutme/$1 [R,L]

如果您希望它是永久性的,您可以将标志更改为
[R=301,L]

,因为您使用的是
.htaccess
,所以您不会尝试匹配前面的
/
。如您的示例所示,使用
mod_rewrite
,您应该能够使用:

RewriteRule ^about/(.*)$ aboutme/$1 [R,L]

如果你想要它是永久的,你可以把标志改为<代码> [R=301,L] < /代码> .< /P>谢谢,但是我想用<代码> RewriteRule < /代码>这样做。你可能仍然想考虑301个重定向用于SEO目的。谢谢,但是我想这样做,使用<代码> RewriteRule < /代码>。你可能仍然想考虑301重定向搜索引擎优化的目的。