web-nomad
web-nomad

Reputation: 6013

.htaccess redirect with get variable

How do i redirect stp.html?as=dm to ctr.php?as=dm.

I've tried the following:

Options +Includes

AddType text/html .html
AddHandler server-parsed .html

XBitHack on

RewriteEngine On
RewriteBase /

RewriteRule ^stp\.html?(.*)$ /resources/ctr.php?$1

Thanks

Upvotes: 1

Views: 33

Answers (2)

Jon Lin
Jon Lin

Reputation: 143966

You don't need to match against the query string. It's not part of what's used the match the pattern against. It will automatically get appended to the rule's target:

RewriteRule ^stp\.html$ /resources/ctr.php [L,R]

Upvotes: 1

Phil Perry
Phil Perry

Reputation: 2130

RewriteEngine On
RewriteRule  stp\.html  ctr.php [L]

It should automatically bring over the entire Query String (?as=dm). Did you mean the '?' as ".htm OR .html", or were you trying to pick up the query string?

Note that you can suppress copying over of the Query String by ending the replacement pattern with ?. You can replace the old Query String with your own by specifying it in the replacement. You can specify a new Query String and copy over the old one by using the [QSA] flag.

Upvotes: 1

Related Questions