Results 1 to 8 of 8
  1. #1

    Question mod_rewrite and subdomain redirection...

    Alright ive been fooling around with mod_rewrite for a few days and have failed to figure out what is probably so obvious i should be beaten, but what i need to do is for example i have /somedir/ which can be accessed from and by default, also i want to point to /somedir/ if it exists otherwise just go to the default /somedir/

    hopefully i have explained it well enough and maybe this can be quickly resolved any ideas?

  2. #2
    Join Date
    Jan 2002
    I will try to help, but first I need something more clear.

    For example:

    How do you know which part is the domain and which part is the subdomain?
    Ahmad Alhashemi
    PHP, Apache, C, Python, Perl, SQL
    18 related BrainBench certificates

  3. #3
    what i would like for example... & -> /somedir/ -> /somedir/ -> /somedir/

    if /somedir/ dosent exist it would just show the default domains website in this case /somedir/ being or

    is this what you were asking?

    the domain would be defined manualy in each mod_rewrite file i guess unless their is an easier way. but whatever is set say being the domain the defaults would be and

  4. #4
    Join Date
    May 2001
    Dayton, Ohio
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} * [NC] 
    RewriteCond %{HTTP_HOST} ! [NC] 
    RewriteRule ^/(.*)$ /home/username/public_html/%{HTTP_HOST}/$1 [L] 
    ServerAlias *
    This would make
    -Mat Sumpter
    Director, Product Engagement
    Penton Media

  5. #5
    Join Date
    Jan 2002

    It's a bet complicated.
    Is it for a specific domain?
    or you want to apply that to all the domains on your server?
    Ahmad Alhashemi
    PHP, Apache, C, Python, Perl, SQL
    18 related BrainBench certificates

  6. #6
    id like to apply it to all domains on a server, but im willing to setup each domain as needed manualy if thats what it takes.

  7. #7
    Join Date
    Jul 2000
    I found a solution for your problem.
    Put this in your httpd.conf under the virtual host.
    RewriteEngine On
    RewriteMap subdomain txt:/somedir/
    RewriteCond %{HTTP_HOST} ^(.*)\.domain\.com
    RewriteCond %{REQUEST_URI} !/icons/
    RewriteRule ^/(.*) ${subdomain:%1|/somedir/}/$1
    The map file looks like this.
    subdomain       /somedir/
    subdomain2     /somedir/
    subdomain3     /somedir/
    - dom
    [ voodooweb hosting ]
    [email protected]
    Internet Solutions made in Switzerland

  8. #8
    im about to try this out, will this still work correctly as in the and will show whats in the root dir ala /somedir/

    -- update: i missunderstood you, but thats an intresting way of doing it. not quite what i was looking for though
    Last edited by nricciar; 07-24-2002 at 03:18 AM.

Posting Permissions

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