Muaaz Khalid
Muaaz Khalid

Reputation: 2249

Htaccess Rewrite Rule to have a Friendly URL

I'm using godaddy hosting and my domain is pointed to the directory named "abc" I created a directory "temp" under "abc" directory and placed an .htaccess file under "temp" directory.

I want to rewrite url as follow

http://www.mywebsite.com/temp/VARIABLE_VALUE/VARIABLE_FILENAME.php?id=12&c=usa

to

http://www.mywebsite.com/temp/VARIABLE_FILENAME.php?var=VARIABLE_VALUE&id=12&c=usa

my .htaccess file consists of the following code.

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^-]*)$ /temp/index.php?var=$1 [L]

But, it gives me 404 error.

Upvotes: 1

Views: 109

Answers (1)

anubhava
anubhava

Reputation: 786031

You can use this rule in

Options +FollowSymLinks
RewriteEngine On
RewriteBase /temp/

RewriteRule ^([^/]+)/([^.]+\.php)$ $2?var=$1 [L,QSA]

Upvotes: 2

Related Questions