Joe
Joe

Reputation: 2452

How to do this rewrite rule for apache htaccess?

I would like to make rewrite that would take get.domain.com to domain.com/get.php alongside all GET parameters.

Example: get.domain.com?v=64 would change to domain.com/get.php?v=64

Also, if possible, I would like the request URL on the webpage not to change, and remain as get.domain.com?v=64 to the user.

My current attempt:

RewriteCond %{HTTP_HOST} ^(www\.)?get\.domain\.com$ [NC]
RewriteRule ^ http://domain.com/get.php [NE,R=301,L]

It does translate get.domain.com to domain.com/get.php but paramters are not transferred and the URL is changing.

Any idea how to do that?

Upvotes: 1

Views: 16

Answers (1)

anubhava
anubhava

Reputation: 786319

You can use this rule:

RewriteCond %{HTTP_HOST} ^(?:www\.)?(get)\.domain\.com$ [NC]
RewriteRule ^/?$ %1.php [L]

Upvotes: 1

Related Questions