Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Apache Mod_Rewrite problem

Options
  • 27-11-2003 5:27pm
    #1
    Registered Users Posts: 14,148 ✭✭✭✭


    Hey guys,

    wondering if anyone can help me with this. I have a windows2k server machine serving webpages using apache 2.0.48

    I have two virtual hosts set up (DNS has been dealt with also): vhost.domain.extension. Both of these point to other machines on the internal network

    eg. vhost1.domain.extension -> [url]http://www.domain.extension:port/somedir/[/url]


    I'm using the mod-rewrite function in apache and the apache configuration entry for this particular vhost is as follows:
    <VirtualHost *>
    	ServerName vhost1.domain.extension
    	ServerAlias vhost1
    	ErrorLog logs/vhost1_error.log
    	CustomLog logs/vhost1_access.log common
    	RewriteEngine On
    	RewriteCond %(REQUEST_URI) =^vhost1\.domain\.extension$ [NC]
    	RewriteRule ^/(.*) [url]http://www.domain.extension:port/somedir/[/url]$1 [L,R]
    </VirtualHost>
    

    Can anyone spot anything wrong with this?


Comments

  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    Originally posted by Lemming
    Hey guys,

    wondering if anyone can help me with this. I have a windows2k server machine serving webpages using apache 2.0.48

    I have two virtual hosts set up (DNS has been dealt with also): vhost.domain.extension. Both of these point to other machines on the internal network

    eg. vhost1.domain.extension -> [url]http://www.domain.extension:port/somedir/[/url]


    I'm using the mod-rewrite function in apache and the apache configuration entry for this particular vhost is as follows:
    <VirtualHost *>
    	ServerName vhost1.domain.extension
    	ServerAlias vhost1
    	ErrorLog logs/vhost1_error.log
    	CustomLog logs/vhost1_access.log common
    	RewriteEngine On
    	RewriteCond %(REQUEST_URI) =^vhost1\.domain\.extension$ [NC]
    	RewriteRule ^/(.*) [url]http://www.domain.extension:port/somedir/[/url]$1 [L,R]
    </VirtualHost>
    

    Can anyone spot anything wrong with this?

    At a guess I reckons your RewriteRule has to change from a domain name to a directory in your ServerRoot somewheres.


    Like so

    RewriteCond %(REQUEST_URI) =^vhost1\.domain\.extension$ [NC]
    RewriteRule ^/(.*) /somedir/[/url]$1 [L,R]

    maybe


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by Typedef
    At a guess I reckons your RewriteRule has to change from a domain name to a directory in your ServerRoot somewheres.

    Well, here's the thing.

    vhost1 is on the same box, just running from IIS (please don't ask) on a different port 'n'

    vhost2 is on a seperate box inside the network listening on port 'x'

    I need to redirect to these ports at these locations.

    eg.
    vhost1 -> http://www.domain.extension: port/somedir/
    vhost2 -> http://xxx.xxx.xxx.xxx: port/somedir/


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Why is there an equals sign in the RewriteCond? Could be something I've missed in the docs, but it doesn't look right to me.
    RewriteCond %(REQUEST_URI) [b]=[/b]^vhost1\.domain\.extension$ [NC]
    
    Also, this seems like overkill to me. Since you've got a dedicated vhost block already, why not just use Redirect? Or you could put the rewrite rules in the first vhost block and catch requests for both domains there, since the first vhost always picks up the slack. And why are you logging a redirection? And why are you redirecting in the first place, why not just point at the other machines? And why is the sky blue? And why does Typie use Slackware? :)

    adam


  • Registered Users Posts: 14,148 ✭✭✭✭Lemming


    Originally posted by dahamsta
    And why are you logging a redirection?

    I threw in the logging because it wasn't working and wanted to see if it was even being picked up, which it wasn't.

    And why are you redirecting in the first place, why not just point at the other machines?

    Under the old machine (linux) I could listen by port and just tunnel to the other machines. Being the *magnificent* beast that it is, Microwank2k server wont let me do squat.

    And why is the sky blue? And why does Typie use Slackware? :)

    'cause ... eh ... actually that's a really good question. Why DO you use Slackware Typie? :D


  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    I threw in the logging because it wasn't working and wanted to see if it was even being picked up, which it wasn't.

    Ah right. In case you aren't aware, mod_rewrite has a logging facility (RewriteLog & RewriteLogLevel) which can be quite useful for more complex RewriteRules.

    Under the old machine (linux) I could listen by port and just tunnel to the other machines. Being the *magnificent* beast that it is, Microwank2k server wont let me do squat.

    Fair excuse. Fire a shotgun at it is my advice.

    adam


  • Advertisement
Advertisement