Ten Sleep
Ten Sleep

Reputation: 1197

301 Redirects behaving strangely

Running into this issue where the redirect in the second line is redirecting to the URL in the first line.

Redirect 301 /academics/degrees http://mydomain.edu/folder1/location1/
Redirect 301 /academics/degrees/phd http://mydomain.edu/folder1/location2/

At first I thought it had something to do with the locations to be redirected containing hyphens, but haven't been able to find anything on that.

Does it have something to do with the locations to be redirected sharing the same folder/permalink structure?

I've never encountered this before and am totally lost. I tried RedirectMatch but that didn't have any effect.

Upvotes: 1

Views: 21

Answers (1)

anubhava
anubhava

Reputation: 785581

It is because /academics/degrees matches both URLs and rule for /academics/degrees/phd never fires. Either change the order of your rule OR better use RedirectMatch with regex capability to match only desired URL pattern:

RedirectMatch 301 ^/academics/degrees/?$ http://mydomain.edu/folder1/location1/
RedirectMatch 301 ^/academics/degrees/phd/?$ http://mydomain.edu/folder1/location2/

Make sure to clear your browser cache before testing this change.

Upvotes: 1

Related Questions