CodeIgniter Forums

Full Version: Htaccess + Subdomain mapping to controller doesn't work.I tryed everything.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Twisted1919[/eluser]
I have a normal url that looks like :
http://www.mysite.com/home/prizes/USERNAME
I want to remap it , using DNS wildcards and htaccess to
http://username.mysite.com
I have this htaccess :
Code:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^dev.mysite.com$
RewriteCond %{HTTP_HOST} !^www.mysite.com$
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]*).mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/home/prizes/%1 [L]

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

  
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

But will not work , loading www.mysite.com , loads normally but when accessing http://username.mysite.com i get a HTTP 500 error code .
I have read almost all the threads on this forum , but nothing seems to work.
Also , i have a http://dev.mysite.com where i store a copy of the website for development , now when accesing it , it loads the live site instead of the dev one .
I really don't know what to do further ...
Any help would be highly appreciated .
Thank you .

El Forum

[eluser]GIN[/eluser]
I'm not sure, but may be you need separate your .htaccess on 2 parts.
The root .htaccess will be:
Code:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^dev.mysite.com$
RewriteCond %{HTTP_HOST} !^www.mysite.com$
RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]*).mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/home/prizes/%1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

and in you sub folder .htaccess will be:
Code:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /  # I'm not sure about this

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

  
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Just try =)

El Forum

[eluser]Twisted1919[/eluser]
What subfolder for the second htaccess ?
The subfolders actually does not exists , these are CI controllers , so i'm not quite sure i understand your answer ...

El Forum

[eluser]rogierb[/eluser]
You need to split thing up a bit more so you process dev/www/system before the username thingy

Code:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(^dev|^www).mysite.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]*).mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/home/prizes/%1 [L]

</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

El Forum

[eluser]GIN[/eluser]
Oh.. I got it. Sorry.
May be you'll find something here http://ellislab.com/forums/viewthread/47523/

El Forum

[eluser]Twisted1919[/eluser]
@ rogierb - Still , i end up with the 500 error ... and still i cannot access dev.mydomain.com , any other thoughts ?
@GIN - NP , thanks for trying Smile

El Forum

[eluser]rogierb[/eluser]
And something like:

Code:
RewriteBase /
RewriteCond %{HTTP_HOST} ^(^dev|^www).mysite.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://%1.mysite.com/index.php/$1 [L]

RewriteCond %{HTTP_HOST} ([a-zA-Z0-9]*).mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/index.php/home/prizes/%1 [L]

El Forum

[eluser]Twisted1919[/eluser]
Okay , this becomes very strange , all i get is that 500 error ...
I don't know why , i read your code , and seems like it should be working , but it doesn't .
I really don't know what's wrong , does somebody had this working ?
@ rogierb - thanks for your help , if you have other ideas , i'll try them as well Smile