Salman
Salman

Reputation: 3726

.htaccess rewrite with url masking

I need to do a url rewrite maintaining following condition:

What I tried so far: The following results in 500 error.

RewriteCond %{HTTP_HOST} ^(*.)?domain\.net$
RewriteRule ^(/)?$ http:// ip:port/folder/$1 [L,R,QSA]

The following works without the masking:

RewriteCond %{HTTP_HOST}   !^www\.domain\.net [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http:// ip:port/folder/$1 [L,R,QSA]

Upvotes: 0

Views: 2206

Answers (1)

sceid
sceid

Reputation: 165

You can do this only if ip:port and domain.net refers to the same server. Otherwise you have to use some script that pulls the remote content from ip:port for a request to domain.net, if you want to hide ip:port.

Otherwise you can proxy the request to another server using the [P] flag.
See: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_p

Upvotes: 1

Related Questions