Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2004
    Location
    The Netherlands
    Posts
    551
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Mod rewrite on a subdomain with redirects

    I have a subdomain, and I want to send uri's to the new subdomain using a redirect:

    http://www.mydomain.com/subdomain/^anythinghere$
    must go to :

    http://subdomain.mydomain.com/^anythinghere$

    I also want mod rewrite:

    http://subdomain.mydomain.com/^anythinghere$/

    must be rewritten as:

    http://subdomain.mydomain.com/index.php?q=^anythinghere$

    How would I do this?
    CATdude about IE6: "All your box-model are belong to us"

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    In you main domain root directory a .htaccess files with
    Code:
    RewriteEngine ON
    RewriteRule ^/subdomain/?$ http://subdomain.mydomain.com/ [R,QSA]
    RewriteRule ^/subdomain/(.*)/?$ http://subdomain.mydomain.com/$1 [R,QSA]
    And in the subdomain root directory a .htaccess files with
    Code:
    RewriteEngine ON
    RewriteRule ^(.*)$ index.php?q=$1 [QSA]
    (i haven't actually tested this so if there's a problem just ask)
    Ps. remember to change subdomain in the first .htaccess file to your subdomain's name.

  • #3
    Regular Coder
    Join Date
    Nov 2004
    Location
    The Netherlands
    Posts
    551
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, that's exactly what I was looking for. I understand that [R] will send a redirect header to the browser, but what does [QSA] do? Oh yeah, using the index.html to index.php?q=index with the R flag would break the use of mod_rewrite, hahaha.

    [edit:NVM.]
    This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.
    [/edit]
    Last edited by mrruben5; 07-15-2005 at 12:19 AM.
    CATdude about IE6: "All your box-model are belong to us"

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Posts
    360
    Thanks
    0
    Thanked 17 Times in 17 Posts
    if you want http://subdomain.yourdomain.com/ to go to index.php?q=index you can use this:
    Code:
    RewriteEngine ON
    RewriteRule ^$ index.php?q=index [QSA]
    RewriteRule ^(.*)$ index.php?q=$1 [QSA]

  • #5
    Regular Coder
    Join Date
    Nov 2004
    Location
    The Netherlands
    Posts
    551
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Another mod rewrite question. Can I "cloak" an url with mod_rewrite?

    eg: http://www.encyshop to http://www.iceshop.nl/encyclue/store?
    CATdude about IE6: "All your box-model are belong to us"


  •  

    Posting Permissions

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