wesbos
wesbos

Reputation: 26317

htaccess 301 redirect root only

I have a site in a folder called patients

urls look like this:

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

I want to redirect

site.com/patients/post-name → newsite.com/post-name

AND

site.com/patients/ → newsite.com/

I've tried this, but site.com/patients still directs to 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 ?

Upvotes: 0

Views: 481

Answers (2)

ChrisArchitect
ChrisArchitect

Reputation: 11

REDIRECT 301 /patients http://newsite.com

does that work?

Upvotes: 1

paulsm4
paulsm4

Reputation: 121829

In general, there are two solutions for "301" POST error:

1) Always add a trailing backslash to your "POST" URL (preferred)

2) Create an "Alias" in your httpd.conf file for the "POST" URL:

In your case, you want a redirect for two purposes. Check out this link (closed as off-topic, but still useful):

Upvotes: 0

Related Questions