Christophe
Christophe

Reputation: 4828

htaccess: how to redirect every url that starts with http://example.com/shop

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

so I have:

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

Upvotes: 1

Views: 4622

Answers (1)

Gumbo
Gumbo

Reputation: 655269

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.

Upvotes: 5

Related Questions