简体   繁体   English

htaccess 301仅重定向root

[英]htaccess 301 redirect root only

I have a site in a folder called patients 我在一个名为患者的文件夹中有一个网站

urls look like this: 网址看起来像这样:

http://site.com/patients/post-name http://site.com/patients/post-name

I want to redirect 我想重定向

site.com/patients/post-name → newsite.com/post-name site.com/患者/帖子名称→newsite.com/帖子名称

AND

site.com/patients/ → newsite.com/ site.com/patients/→newsite.com/

I've tried this, but site.com/patients still directs to newsitesite.com/patients 我已经尝试过了,但是site.com/ Patients仍然指向newsitesite.com/ Patients

Redirect 301 ^/patients/$ http://www.newsite.com/
Redirect 301 / http://newsite.com/

Does htaccess have some ssort of regex to match just the root of /patients/ and then another one for /patients/whatever-comes-next ? htaccess是否有某种正则表达式来匹配/ Patients /的根,然后再匹配/ Patient / whatever-comes-next的根

REDIRECT 301 /patients http://newsite.com

那样有用吗?

In general, there are two solutions for "301" POST error: 通常,对于“ 301” POST错误有两种解决方案:

1) Always add a trailing backslash to your "POST" URL (preferred) 1)始终在您的“ POST” URL中添加尾部反斜杠(首选)

2) Create an "Alias" in your httpd.conf file for the "POST" URL: 2)在httpd.conf文件中为“ POST” URL创建一个“别名”:

In your case, you want a redirect for two purposes. 在您的情况下,您需要重定向有两个目的。 Check out this link (closed as off-topic, but still useful): 签出此链接(已关闭,但仍然有用):

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM