0

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?

2
  • 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. Commented 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 help Commented Sep 17, 2013 at 15:04

2 Answers 2

1

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]
Sign up to request clarification or add additional context in comments.

3 Comments

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?
@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 is
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.
0

if apache server

.htaccess

update

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . products.php

1 Comment

Thanks for your guide though I used @Jon Lin's solution above as it was more in dept to solving my challenge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.