test
test

Reputation:

Apache redirect

I would like to redirect a URL using RedirectMatch within Apache eg,

/test/one/?? redirect to /test/two/??

where the ?? represents any string that follows

The redirect i'm using below does a straight redirect but doesnt match any string after... RedirectMatch Permanent ^/test/one?$ /test/two/

Thanks alot

Upvotes: 0

Views: 1582

Answers (2)

Samir Talwar
Samir Talwar

Reputation: 14330

You can use mod_rewrite for this:

RewriteEngine On
RewriteBase /
RewriteRule ^/test/one/(.*) /test/two/$1 [L,R=301]

The R flag redirects the page rather than internally rewriting the URI. 301 is the HTTP status code for "Permanently Moved" - if you'd rather use another, you can change it to one of these.

Upvotes: 0

user142019
user142019

Reputation:

RewriteEngine ON
RewriteBase /
RewriteRule ^/test/one/(.+)$ /test/two/$1

if that does not work, change ^/test/one into ^test/one

make sure mod_rewrite is enabled

Upvotes: 2

Related Questions