Forum Moderators: phranque
I am new in writing mod_rewrite code. Please have a view on my code.
My current URL is -
1) http://mysite.com/bookinfo.php?book=abc
I want it to rewrite it into http://mysite.com/bookinfo/abc
for achiving this i wrote this rule in .htaccess
RewriteRule ^bookinfo/([^/]+)/?$ /bookinfo.php?book=$2 [L]
2)http://mysite.com/books.php?category=abc
I want rewrite it into
http://mysite.com/books/category/abc/
for achiving this i wrote this rule in .htaccess
RewriteRule ^books/([^/]+)/([^/]+)/?$ /books.php?$1=$2 [L]
Means final .htaccess code is -
RewriteEngine On
RewriteRule ^bookinfo/([^/]+)/?$ /bookinfo.php?book=$2 [L]
RewriteRule ^books/([^/]+)/([^/]+)/?$ /books.php?$1=$2 [L]
Please suggest me is my .htaccess file is okay for my purpose or it hase erors.
Warm regards,
Vineet