1

I am totally newbie when it comes to .htaccess or Apache. I don't know how it works.

My URLs are like http://localhost/category.php?category=something and I'd like to get the variable value as something in category.php but I'd like to show the URL as http://localhost/something

How can I do this? Please help. Thank you in advance.

1

I haven't tested this exact string but in your htaccess file you can try:

Options +FollowSymLinks

RewriteEngine On

 RewriteCond %{QUERY_STRING} ^(.*&)category=([^&]+)(&.*)?$ [NC]

 RewriteRule ^category\.php$ /%2? [R=301,L]

How familiar are you with regular expressions? That's probably the biggest hurdle to get over with mod_rewrite.

This particular version is intended to work for multiple parameters (optionally) and category can be first or not first. The other parameters if present are just discarded -- they still sent to your php code, just don't appear in URL.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .