Site url: http://www.sitename.com/products.php?cat=1&page=1 OR http://www.sitename.com/products.php?cat=1 OR http://www.sitename.com/products.php Code (markup): Want it to become like this: http://www.sitename.com/products/category/1/page/1 OR http://www.sitename.com/products/category/1 OR http://www.sitename.com/products (Respectively) Code (markup): Mod_Rewrite Code i am using: <IfModule mod_rewrite.c> Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^products/category/(.*)/page/(.*)$ products.php?cat=$1&page=$2 [L] RewriteRule ^products/category/(.*)$ products.php?cat=$1 [L] RewriteRule ^products$ products.php [L] </IfModule> Code (markup): But its not working at all Can anyone tell me where am i going wrong ?
If this doesn't work, 1) please check that your server supports mod rewrite. 2) Ensure the correct path of "products.php" 3) Verify your server error log
Thanks vishwaa for helping but still its not working 1) i guess if redirection through htaccess is working so it should imply that mod_rewrite is also working ... do correct me if i am wrong !?! 2) products.php file is in the same folder as the .htaccess file. 3) there are no error logs for this file or domain name Can you please get me out of this strange problem ? Edit: Opened a support ticket to reinstall mod_write on the server... hope that does the trick... but still waiting for it to work
When i am opening the old URL's: http://www.sitename.com/products.php?cat=1&page=1 OR http://www.sitename.com/products.php?cat=1 OR http://www.sitename.com/products.php Code (markup): They are working like they should....But if i manually type in the new URL's http://www.sitename.com/products/category/1/page/1 OR http://www.sitename.com/products/category/1 OR http://www.sitename.com/products (Respectively) Code (markup): I get the page but without any CSS styling or images just text.... what does that mean ?
So you are getting the correct pages with mod written urls but css and images are missing, right? If so, mod rewrite works fine in your case. Mod rewrite just make your new urls work. You will need to change the html/php code to make the css/images/urls to work properly. For ex. 1) use absolute path like "/css/style.css" instead of "../css/style.css" for css/images/urls wherever possible. 2) change the html code to reflect the new urls ("/products.php?cat=1&page=1" should be "/products/category/1/page/1")
yes i am getting the page without any CSS or images but that they are coming only when i manually type in the URL they are not getting converted by there own And once they are getting rewritten on there own then i will have to change the relative paths like css/style.css to absolute ones http://sitename.com/css/style.css Code (markup): as you say But that is the case only when the URL are getting rewritten on there own as for now i have to manually enter the new URL....
Rashy, mod rewrite does nothing else other than translating your seo friendly url to actual url. YOU only have to apply the new url structure to your html code. Until you do this, you will have to manually enter the new url and no conversion will occur as you expect. Hope you understand this.
oh i didn't knew that i have to change my URL structure too i thought by using mod_rewrite only my URL structure will automatically get rewritten ok now i get it thanks for clearing the things out