apachemod-rewriteotrs

RewriteRule from mod_rewrite only works as redirect with added http://%{HTTP_HOST}, but doesn't work at all without it


I use this apache config file on centOs 7. This file is is already set up to run

/opt/otrs/bin/cgi-bin/customer.pl

on my machine on a call to http://localhost/opt/customer.pl

I wanted to use mod_rewrite to run the customer.pl and give it the called url as a parameter. So i want to enter the url: localhost/HTMLData/1/Default.htm

and have it call:

/opt/otrs/bin/cgi-bin/customer.pl

with the parameters

?Action=CustomerHTML;Subaction=ContentCall;Target=1/Default.htm

That works somewhat with:

RewriteEngine on
RewriteRule ^/HTMLData/(.*)$ http://%{HTTP_HOST}/otrs/customer.pl?Action=CustomerHTML;Subaction=ContentCall;Target=$1

But i this is a redirect (because of the added "http://%{HTTP_HOST}"). What i need is, that the webrowser keeps thinking http://localhost/HTMLData/1/ is where to get the files. But if i remove the "http://%{HTTP_HOST}", it doesn't work at all. But the examples i found on the internet said i should work this way. What do i have to change, to have the redirect only internaly without giving the browser the real url back?

Thank you


Solution

  • In case someone else might need this in the future. What fixed it for me was adding

    RewriteEngine on
    RewriteRule ^(.*)$ $1
    

    under "". I don't know why, but at least i can use the internal redirect now.