Nick
Nick

Reputation: 1570

.htaccess Folder redirect

I try to make redirect in my folder:

Redirect /promotion/ /newpromotion
Redirect /promotion/first/ /new/first/

And now if I try to open http://mysite.com/promotion/first I open http://mysite.com/newpromotion/new/first but I need http://mysite.com/new/first

How can I fix it?

UPD: It's crazy but I did it:

   Redirect /promotion/ /newpromotion
   Redirect /promotion/first/ /new/first/
   Redirect /newpromotion/new/first /new/first/

Solution: Need to reverse the 2 directives:

Redirect /promotion/first /new/first
Redirect /promotion /newpromotion

Upvotes: 0

Views: 1545

Answers (2)

Jon Lin
Jon Lin

Reputation: 143856

Redirect directive connects to path nodes together, so when you have:

Redirect /promotion/ /newpromotion

It means anything starting with /promotion/ gets redirected to /newpromotion/. e.g:

  • /promotion/ -> /newpromotion/
  • /promotion/foo.html -> /newpromotion/foo.html
  • /promotion/first/ -> /newpromotion/first/

You just need to reverse the 2 directives:

Redirect /promotion/first /new/first
Redirect /promotion /newpromotion

Upvotes: 1

rchiriboga
rchiriboga

Reputation: 187

Try

Redirect /promotion/first/ /new/first/ Redirect /promotion/ /newpromotion

the more detailed should come first.

----- EDIT ------

Try this:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule ^/promotion/first/$ /new/first/ [L]
RewriteRule ^/promotion/$ /newpromotion/ [L]

Upvotes: 2

Related Questions