Pixel
Pixel

Reputation: 1976

Url rewriting .php to .asp

I would like to redirect my url :
www.site.fr/displayfichebien.asp?idref=250 to www.site.fr/detail_offre.php?offre=250

I have a PHP website and the link www.site.fr/detail_offre.php?offre=250 work.

But when i put www.site.fr/displayfichebien.asp?idref=250 in my browser i have a 404 error.

htaccess

Options +FollowSymlinks
RewriteEngine on
RewriteRule displayfichebien.asp?idref=([0-9]+)$ detail_offre.php?offre=$1 [QSA,L]

Upvotes: 1

Views: 51

Answers (1)

anubhava
anubhava

Reputation: 785266

You cannot match QUERY_STRING in RewriteRule. You need to use a RewriteCond.

RewriteEngine On

RewriteCond %{QUERY_STRING} ^idref=(\d+) [NC]
RewriteRule displayfichebien\.asp$ detail_offre.php?offre=%1 [QSA,L,NC]

Upvotes: 3

Related Questions