I have a URL http://www.domain.com/products.php?cat=women-clothing-tops and want to re-write it to http://www.domain.com/women-clothing-tops, how do I go about this? Is it just a URL re-write or there are other things I need to do to get it re-written?
-
Did you already try some things? I could copy and paste this page (URL Rewriting for Beginners) but maybe it's best for you to just go there.Rik– Rik2013-09-17 15:01:12 +00:00Commented Sep 17, 2013 at 15:01
-
I've been there but didn't get at what I needed. It's the reason why I'm here to seek further helpOmniPotens– OmniPotens2013-09-17 15:04:33 +00:00Commented Sep 17, 2013 at 15:04
Add a comment
|
2 Answers
Try adding these rules to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9-]+)$ /products.php?cat=$1 [L]
3 Comments
OmniPotens
Does I still get the value of "cat" in the URL "domain.com/products.php?cat=women-clothing-tops"? Please, how exactly do I use my GET method so I can get the correct page?
Jon Lin
@OmniPotens If you go to
http://www.domain.com/women-clothing-tops, you will get served the page http://www.domain.com/products.php?cat=women-clothing-tops, that's what a rewrite isOmniPotens
Thanks. I'll implement. I just wanted to be sure I was doing the correct thing so I don't break my codes and fall into deep confused state.
if apache server
.htaccess
update
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . products.php
1 Comment
OmniPotens
Thanks for your guide though I used @Jon Lin's solution above as it was more in dept to solving my challenge.