Results 1 to 3 of 3
  1. #1

    Setting up mod_rewrite with virtualhost for multiple domains

    I set up an IP-based VirtualHost, so that my customers can just point their domains to my IP and all those domains will point to a single location on my server.

    Now, I'm trying to create an .htaccess file with mod_rewrite for SEO-friendly URLs. In the past, I have always hard coded the domain name into my .htaccess file. In this case, I can't do that, because I will have multiple domains using that same .htaccess file.

    How do I do this?

    I would like to create the effect below (see the HTTP_HOST part)...
    RewriteEngine On
    RewriteBase /
    ReWriteRule ^([0-9]{5})-([a-z-]+)-abcd.*$ http://%{HTTP_HOST}/file.php?var1=$1&var2=$2 [NC]
    Please let me know if you any clarification. Thanks!


  2. #2
    Join Date
    Aug 2005
    Durham, NC USA
    You can either

    A) Put the rewrite rules into the VirtualHost sections of the httpd.conf file. This is probably the best solution, because you really shouldn't be using .htaccess unless you need to have a filesystem-based rule.

    B) Set up a series of rules using the RewriteCond to select between the various domains. (see here)
    Netmar Web Services - Reliable Web Hosting for 15 years
    Shared hosting, business hosting, domain name registration, and VMware virtual servers
    Specializing in Drupal hosting
    Call 866-363-8627 (toll-free) and ask about our Drupal accounts

  3. #3
    You can also specify global rewrite rules (if applicable), and add this line to all virtualhosts (after the "RewriteEngine On" directive):
    RewriteOptions Inherit

Similar Threads

  1. Virtual sub-domains through mod_rewrite
    By Jatinder in forum Domain Names
    Replies: 6
    Last Post: 07-16-2008, 02:09 AM
  2. (Moved to a new server) Urgent help needed in setting up dynamic VirtualHost
    By dtang in forum Hosting Security and Technology
    Replies: 1
    Last Post: 10-07-2006, 01:35 PM
  3. Replies: 5
    Last Post: 08-21-2005, 07:16 AM
  4. IIS Issue Setting Up Multiple Domains
    By hostedvalue in forum Hosting Security and Technology
    Replies: 2
    Last Post: 03-02-2004, 06:45 AM
  5. Setting up multiple domains on one account
    By bert in forum Hosting Security and Technology
    Replies: 2
    Last Post: 10-17-2001, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts