# mod_rewrite problem

## Messiah

Dear all,

I have a problem with mod_rewrite of Apache. I want to cloack an URL for a domain, and it does work with the following:

```

RewriteCond %{HTTP_HOST} ^.*actualdomain.tld$

RewriteRule (.*) http://url.tocloack.tld/$1 [P]

```

It is being cloaked because of the P, which stands for proxy (or proxythrough, I can't recall). I think this needs mod_proxy to be installed.

However, the problem with this is when I go to the url http://actualdomain.tld/index.php?param=1

Then, I am getting a 404 error, while getting http://actualdomain.tld/index.php works fine and shows me the page at http://url.tocloack.tld/index.php

Anyone knows how to solve this?

PS If I replace P with R to redirect, off-course everything works, but hey, I want the domain to be visible in the browser  :Wink: 

----------

## rac

Can you tell what URL is generating the 404 from Apache's access logs?  Might this section from http://httpd.apache.org/docs/mod/mod_rewrite.html be relevant?   *Quote:*   

> Note: There is a special feature: When you prefix a substitution field with http://thishost[:thisport] then mod_rewrite automatically strips it out. This auto-reduction on implicit external redirect URLs is a useful and important feature when used in combination with a mapping-function which generates the hostname part. Have a look at the first example in the example section below to understand this.
> 
> Remember: An unconditional external redirect to your own server will not work with the prefix http://thishost because of this feature. To achieve such a self-redirect, you have to use the R-flag (see below).

 

----------

## Messiah

It was an external redirect, so I cannot see what URL the error log shows. Tomorrow I will test it on 2 servers of my own, so it still will be an external redirect but where I can see the error 404 in the log

I will be back at this one, it's too late now to read *and* understand the passage you posted here

[edit]

Now I have had my cup of coffe I read:

When you prefix a substitution field with http://thishost[:thisport] ....

But in my substitution field I do not have that, so this is not relevant

[/edit]

----------

## Messiah

Ok let's see.

I do a redirect from test.aydin.nu to www.qweb.nl

```

RewriteEngine on                                                                

RewriteCond %{HTTP_HOST} ^test.aydin.nu$                                        

RewriteRule (.*) http://www.qweb.nl/$1 [P]  

```

I get:

```
File does not exist: /var/www/domains/qweb.nl/web/whois.php?type=nl&command=test

```

/var/www/domains/qweb.nl/web/whois.php does exist. Off-course, /var/www/domains/qweb.nl/web/whois.php?type=nl&command=test does not exist. Hmmm...difficult to find any logic here. Could it be that mod_proxy can't handle http post en get methods?

----------

## rac

I think it's more that mod_proxy doesn't handle query-string parts of URLs, or at least some of the docs I found on ProxyPass suggest this.  You might want to try playing with the QSA parameter to mod_rewrite, but I don't hold out a whole lot of hope.  You may just have to use [R].

----------

## Messiah

I did exactly do that, *play around* with QSA, but it didn't help  :Wink: 

----------

