marcnielsen
marcnielsen

Reputation: 25

Redirect does not work through mod_rewrite

Why does not work this regex? The general problem appears after simbol "?", Probable several options, but could not solve the problem.

RewriteEngine on
RewriteRule ^portfolio.php?id=(.*?)$ /index.php?page_id=$1

Upvotes: 0

Views: 15

Answers (1)

anubhava
anubhava

Reputation: 785146

You cannot match query string in RewriteRule pattern, that is used for matching REQUEST_URI only. You will need a RewriteCond for that. Use this rule:

RewriteEngine on

RewriteCond %{QUERY_STRING} ^id=([^&]*) [NC]
RewriteRule ^portfolio\.php$ /index.php?page_id=%1 [L,QSA]

Upvotes: 1

Related Questions