Reputation: 405
After deploying a new site, I'm working to redirect old urls to a single page. Trying both redirects and rewrites. Desired:
/oldurl/page1 => /newurl
/oldurl/page2 => /newurl
The following redirect works, but not entirely. For example:
Redirect 301 /oldurl /newurl
Becomes the following, where page1
should actually be removed
/newurl/page1
The following rewrite doesn't rewrite at all:
RewriteRule ^oldurl/(.*)$ /newurl [R=301,NC,L]
Upvotes: 1
Views: 26
Reputation: 785296
You can use RedirectMatch
for this to get more control via regex patterns:
RedirectMatch 301 ^/oldurl(/.*)?$ /newurl
Upvotes: 1