views:

26

answers:

1

Like the title says, how do I redirect every url that starts with http://site.com/shop to a single page?

so I have:

.... etc, and it should be redirected to http://site.com/new_page

+1  A: 

You can use mod_alias’ RedirectMatch:

RedirectMatch ^/shop(/|$) /new_page

Or mod_rewrite:

RewriteEngine on
RewriteRule ^shop(/|$) /new_page [R]

Note the different pattern for RewriteRule as mod_rewrite removes the contextual path prefix in per-directory rewrites before testing the rules.

Gumbo
mod_alias is different from mod_rewrite i guess? and what does the [R] mean?
krike
@krike: Yes. With the directives of mod_alias you can only process the URI path; with mod_rewrite you can also test other parts of the request like the query or header fields. The `[R]` is to force an external redirect; otherwise the request would only be rewritten internally.
Gumbo
ok thanks :) will try that as soon as I finished the new version of my website :)
krike