Question

I have the following code:

# 301 Redirect Old File
Redirect 301 www.website.com www.website.com/shop

I want the site to automatically redirect anyone visiting www.website.com or website.com to www.website.com/shop, I can't get it to work, can anybody help? Thank you.

Était-ce utile?

La solution

Use RedirectMatch:

RedirectMatch 301 ^/$ http://www.website.com/shop

Note that the regex portion does not include (and cannot include) protocol and hostname. The new URL can include protocol and hostname (or it can just begin with / in Apache >= 2.2.6).

Note that Redirect (not used in the above example) uses prefix matching -- any request beginning with the specified path will match.

Autres conseils

You can do a permanent (301) redirect of your root folder '/':

Redirect 301 / www.website.com/shop

A temporary redirect (302):

Redirect 302 / www.website.com/shop

301 and 302 are different domain redirects, within the same domain you can do:

Redirect / www.website.com/shop
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top