SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Mike99's Avatar
    Join Date
    Oct 2004
    Location
    NJ
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mod_rewrite questions

    Im want to add a rewrite rule that sends any mail.domain.com request to domain.com/webmail

    I have no clue about mod_rewrite and I don't think this would be hard for someone that is familiar with mod_rewrite, so can someone be kind enough to place the code that I need to use here. thanks in advance

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,656
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Mike,

    It would be better to redirect from httpd.conf but I'm not sufficiently knowledgable about Virtual Hosts to tell you how to do it.

    Since your post requested a rewrite rule, I'll offer the following for .htaccess which is where the mod_rewrite module operates.

    Put the following in the root of the mail.domain.com's .htaccess file.
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mail\.example\.com$
    RewriteRule ^(.*)$ http://www.example.com/webmail/$1 [L]
    This will confirm that the host is mail.example.com and send the request (.*) to www.example.com/webmail and the same {REQUEST_URI} string.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    David your code is fine but it will make an external redirection so I'm not sure Mike wants that.


    A suggestion could be to use a proxy, so just add a P to the L flag or you can do this:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mail\.example\.com$ [NC]
    RewriteRule !^webmail/.*$ /webmail%{REQUEST_URI} [L]

    Mike i'm supposing that mail.example.com and example.com points to the same directory, right ?



    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03


Bookmarks

Posting Permissions

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