Reputation: 140
I have to redirect link using .htaccess file. I tried many times but it didn't work.
My link is www.example.com/book_details.jsp?resourceID=35570
I have to redirect to www.example.com/abc/book_details?resourceID=35570
I have tried this but it didn't work
RewriteRule ^book_details\.jsp$
/abc/book_details [NC,L]
RewriteRule ^book_details\.jsp\?resourceID=([0-9]*)$
/abc/book_details?resourceID=$1 [NC,L]
How to do it? Please help me.
Upvotes: 1
Views: 66
Reputation: 753
The following should work:
RewriteEngine On
RewriteRule ^book_details\.jsp$ /abc/book_details [NC,L]
You can test that it works at http://htaccess.madewithlove.be/, and a good information source is http://www.askapache.com/htaccess/htaccess.html
If not, please check whether URL rewriting is allowed on your webserver.
Upvotes: 1
Reputation: 2156
The problem is that RewriteRule
does not match against the query string. The good news is that you don't need to modify the query string in any way, so you can safely ignore it. So your solution will end up looking like this:
RewriteRule ^book_details\.jsp$ /abc/book_details [NC,L]
Upvotes: 1