Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2011
    Thanked 0 Times in 0 Posts

    rewrite url for subdomain (joomla)

    hi, i need your help, and there is the problem

    1. i want to have virtual subdomain like subdomain.example.com

    2. the true url that i want to rewrite is

    3. i have activated joomla SEF so i got new url, like

    4. i want htaccess to rewrite that url (no.3) to something like this
    http: //subdomain.example.com

    5. the code that i put in htaccess is

    ########## Begin - Custom subdomain
    RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com [NC]
    RewriteCond %1 !^www$ [NC]
    RewriteRule ^(.*)$ http://example.com/toko-user?toko=%1 [L]
    ########## End - Custom subdomain

    if i write url in address bar like http: //subdomain.example.com
    i got the page that i want, but the url in address bar change to
    http://example.com/toko-user?toko=subdomain (redirecting) and what i want is not that, but rewrite

    but if i change the script to
    RewriteRule ^(.*)$ /toko-user?toko=%1 [L]

    i got internal server error (500)

    can you tell me what is wrong with my code?

    best regards

  2. #2
    New Coder
    Join Date
    Jul 2011
    Thanked 13 Times in 13 Posts
    Using a domain in the second half of a RewriteRule causes a Redirect to occur, rather than a Rewrite (the same as if you provide the R flag).

    A 500 error is nearly always caused by an infinite loop meaning the address never resolves. Your best bet will be to use RewriteLog and see what's actually happening during your request.

    I don't see how just the rules you have posted could cause this, but I'm assuming you have other RewriteRules in the file that are causing the problem. One thing that I will mention is the fact that the rule you currently have will send all requests to the exact same page. You are not persisting the REQUEST_URI part of the request, not the QUERY_STRING, so all requests to a sub-domain will end up at /toko-user?toko=subdomain regardless of what page is requested from that subdomain.


Posting Permissions

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