Reputation: 23
I am new on .htaccess and want to redirect URL from .htaccess
like:
http://test.example.com/abc/xyz/456adf646asdf
to
http://test.example.com/abc/xyz?id=456adf646asdf
or http://test.example.com/abc/xyz/?456adf646asdf
Please help.
I tried this:
RewriteRule ^(.+)/abc/xyz/$ /abc/xyz?id=$1
but did not work for me..
Upvotes: 0
Views: 86
Reputation: 84
You should also have a RewriteCond to match the incoming URL pattern. Try this to match you explicit case.
RewriteCond %{REQUEST_URI} ^/abc/xyz/(.\*)
RewriteRule (.\*) /abc/xyz?id=%1 [L]
There are of course lots of options. You could also try
RewriteCond %{REQUEST_URI} ^/(.\*)/(.\*)/(.\*)
RewriteRule (.\*) /%1/%2?id=%3 [L]
Where %1 would match 'abc', %2 would match 'xyz', and %3 456adf646asdf in your example.
Is mod_rewrite installed?
Upvotes: 1
Reputation: 840
That won't work. Try this:
RewriteRule ^/abc/xyz/(.+)$ /abc/xyz?id=$1
Upvotes: 0