Welcome Guest, Not a member yet? Register   Sign In
Mod rewrite doesn't work for domain root
#1

[eluser]Unknown[/eluser]
I have my CI install in a subdirectory and I'm using mod rewrite to remove the directory and index.php (www.mysite.com/sub/index.php/controller becomes www.mysite.com/controller).
Everything works fine except the domain root (www.mysite.com) - I get the default apache index, it doesn't rewrite.

I've set up the default controller, so I assume www.mysite.com should trigger it the same as www.mysite.com/sub/index.php would.

As I said, all rewrites work except for the domain root. www.mysite.com/sub/ gives me the default controller, so it seems like there HAS to be something after the domain, but I don't know why. My hosting is with hostgator, could it be something to do with them, or maybe an apache setting?


Here's my .htaccess
Code:
RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ sub/index.php/$1 [L]
#2

[eluser]toopay[/eluser]
try...
Code:
RewriteEngine On
# include your sub directory here
RewriteBase /sub/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ sub/index.php?/$1 [L]
and make sure you set 'base_url' on your config.php under application/config
#3

[eluser]Unknown[/eluser]
That gives the same result on my domain root, and 500 error on everything else.

I tried this also:
Code:
RewriteEngine On
# include your sub directory here
RewriteBase /sub/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

works for everything but the domain root...
#4

[eluser]toopay[/eluser]
I've just notice that you need 2 htaccess file. One in CI Root folder(in this case, 'sub') and you need htaccess in your root folder of your domain (ussually, 'public_html' in shared hosting). If you access www.yoursite.com/sub/ and get the default controller, than everythings works fine. If, you want to redirect your root domain into CI, then you must set htaccess like you have above at your root directory too.




Theme © iAndrew 2016 - Forum software by © MyBB