Raj
Raj

Reputation: 31

The usage of .htaccess to re-write the url

I have written .htaccess to rewrite the following urls :

confirmreg.php

to

http://keralapsctuts.com/confirm-registration.html

and

 confirmreg.php?code=nsfoh98fkjsdf90

to

http://keralapsctuts.com/code/62fdd2ac2709877a81ecfd7dde9d2810/confirm-registration.html

.htaccess Rule is

RewriteRule confirm-registration\.html$ confirmreg.php [QSA,L]
RewriteRule code/(.*)/confirm-registration\.html$ confirmreg.php?code=$1 [QSA,L]

Echo Get not returning the value of the code

echo "Code: ". $_GET['code'];

Upvotes: 1

Views: 35

Answers (1)

Wouter
Wouter

Reputation: 61

Improved code:

RewriteRule ^confirm-registration\.html$ confirmreg.php [QSA,L]
RewriteRule ^code/([0-9a-z]+)/confirm-registration\.html$ confirmreg.php?code=$1 [QSA,L]

Give the RewriteRule a starting ^

RewriteRule ^

Optionally, be more specific in the characters you want to except.

code/([0-9a-z]+)/

Upvotes: 1

Related Questions