I am writing a Apache rewrite rule for following URL - http://localhost/domain/my_directory/sub_cat.php?parent_id=56&name=Anytitle --------to get this:------- http://localhost/domain/my_directory/56/Anytitle ..that am successfully able rewrite it but the prob is that page is now opening for both OLD and NEW URL I wanted to redirect my old URL to New URL i have rewrited thru this rewrite URL Here is my mod_rewrite Code -------- RewriteEngine On RewriteBase /my_directory/ Options +FollowSymLinks +Indexes RewriteRule ([0-9]+)/([a-zA-Z0-9_-]+) http://localhost/domain/my_directory/sub_cat.php?parent_id=$1&name=$2 [L] RewriteCond %{QUERY_STRING} sub_cat\.php\?parent_id=([0-9]+)&name=([a-zA-Z0-9_-]+)$ RewriteRule sub_cat\.php$ http://localhost/domain/my_directory/%1/%2? [R,L] Code (markup): I am not able to redirect the OLD URL to new URL i.e. page is now opening for both: -http://localhost/domain/my_directory/sub_cat.php?parent_id=56&name=Anytitle --as well as-- -http://localhost/domain/my_directory/56/Anytitle I want this /localhost/domain/my_directory/sub_cat.php?parent_id=56&name=Anytitle to be Redirected to this -> /localhost/domain/my_directory/56/Anytitle. Any help !.. Thx in anticipation
You should be fine if you replace the following line: RewriteCond %{QUERY_STRING} sub_cat\.php\?parent_id=([0-9]+)&name=([a-zA-Z0-9_-]+)$ Code (markup): with RewriteCond %{REQUEST_URI} sub_cat\.php\?parent_id=([0-9]+)&name=([a-zA-Z0-9_-]+)$ Code (markup):