1

I need to redirect 2 similar path to same webpage, es

http://www.domain.com/foo --> http://www.domain.com/ok

http://www.domain.com/foo/bar --> http://www.domain.com/ok

I have this in .htaccess:

Redirect 301 /foo http://www.domain.com/ok
Redirect 301 /foo/bar http://www.domain.com/ok

If I go to http://www.domain.com/foo the redirect works, if I go to http://www.domain.com/foo/bar, I have http://www.domain.com/ok/bar and it doesn't work. How can resolve this?

2

Try change order:

Redirect 301 /foo/bar http://www.domain.com/ok
Redirect 301 /foo http://www.domain.com/ok

Also look at mod_rewrite:

http://httpd.apache.org/docs/current/mod/mod_alias.html

#With mod_rewrite
RewriteEngine on
RewriteRule   ^/docs/(.+)  http://new.example.com/docs/$1  [R,L]

#With RedirectMatch
RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1

#With Redirect
Redirect /docs/ http://new.example.com/docs/
  • Good, works! I have change order, thanks! – hellb0y77 Sep 30 '14 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.