logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: newbie with rewritecond headaches!
Author
tintin



Joined: 22 Jan 2013
Posts: 1
Location: UK, London

PostPosted: Wed 23 Jan '13 13:04    Post subject: newbie with rewritecond headaches! Reply with quote

Hello! Have been dropped in the deep end having had no apache/regex experience at all!

Anyway, I have a virtual host with the following working Redirects:

Code:
Redirect HOSTNAME/languagecentre/as/disc/ http://www.library.*****/learning_support/disc
  Redirect HOSTNAME/languacecentre/rlf/index.html http://www.library.******/royal_literary_fund
  Redirect HOSTNAME/languagecentre/brochures/38530.pdf http://www.library.******/royal_literary_fund


I now have a request to redirect all requests to HOSTNAME/languagecentre/.* to another server but keep the existing redirects in place, i.e

Code:
Redirect HOSTNAME/languagecentre/as/disc/ http://www.library.*****/learning_support/disc
  Redirect HOSTNAME/languacecentre/rlf/index.html http://www.library.******/royal_literary_fund
  Redirect HOSTNAME/languagecentre/brochures/38530.pdf http://www.library.******/royal_literary_fund

redirect HOSTNAME/languagecentre/.* http://language-centre.**.uk


I tried adding
Code:
 RewriteRule /languagecentre/.* http://language-centre.**.uk [R,L]


which works but also redirects the rewrites that I need to keep!

I assume I need to use a RewriteCond to allow the original redirects to continue but any other requests to HOSTNAME to be redirected howver, I don't really know where to start and it's doing my head in!

Hope the above makes sense and any help much appreciated!

Steve
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 04 Mar '13 17:13    Post subject: Reply with quote

With mod rewrite you can use %{HTTP_HOST}

see httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewritecond
Back to top


Reply to topic   Topic: newbie with rewritecond headaches! View previous topic :: View next topic
Post new topic   Forum Index -> Apache