Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-06-2011, 07:56 AM   PM User | #1
wanttobe
New to the CF scene

 
Join Date: Oct 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
wanttobe is an unknown quantity at this point
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
http://example.com/index.php?option=com_content&view=article&id=73&Itemid=267&toko=subdomain

3. i have activated joomla SEF so i got new url, like
http://example.com/toko-user?toko=subdomain

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
wanttobe is offline   Reply With Quote
Old 10-06-2011, 08:48 AM   PM User | #2
Cags
New Coder

 
Join Date: Jul 2011
Posts: 67
Thanks: 0
Thanked 13 Times in 13 Posts
Cags is an unknown quantity at this point
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.
Cags is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:45 PM.


Advertisement
Log in to turn off these ads.