Reputation: 679
I have URLs that look like mysite.com/go/somevalue and I want to redirect them to mysite.com?shorturl=somevalue. Think of it as a branded url shortener.
I have tried the following among other incarnations. I think the problem is with the question mark in the results.
RedirectMatch 301 /go(.*) %3F$1
RedirectMatch 301 /go(.*) \?$1
RewriteRule ^.*/go/(.*)$ \?shorturl=$1
Upvotes: 1
Views: 52
Reputation: 785058
This RedirectMatch
should work:
RedirectMatch 301 ^/go/(.+)$ /?$1
Upvotes: 1
Reputation: 143876
You don't want to escape the ?
if you want tha tas part of the query string:
RewriteRule ^.*/go/(.*)$ ?shorturl=$1
The other two statements are mod_alias redirects, which will redirect the browser and cause the location bar to change. If that's what you want, you can add a [L,R=301]
to the end of the rewrite rule and not have a need for the RedirectMatch
lines
Upvotes: 0