Reputation: 23544
I have a CI app that after switching servers, doesn't seem to route properly.
In my config I have
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
This should allow both query string parameters and url segments.
So this, should in theory work (as it is on the old server):
http://www.domain.com/register?param=something
However, no matter what URL I go to it only shows the index.
So if I go to http://www.domain.com/register
It shows this in the address bar, however it doesn't get the register controller, it's showing the index.
If I change the 'uri_protocol' to REQUEST_URI, it works. But then query string parameters won't.
My .htaccess is
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico|license.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ /? [L]
Any ideas what the issue could be? Like I say, it's working on a different server. So, I'm thinking something to do with apache perhaps?
Thanks a lot!
Upvotes: 1
Views: 2251
Reputation: 942
Try removing the ./ before the index.php
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
You should actually be able to get by with just these lines
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
If you have the codeigniter in a directory, you may need to add the rewrite base directive depending on your server setup.
RewriteBase /directory/
Upvotes: 0
Reputation: 34632
I'd guess, RewriteCond $1
never evaluates to true and no redirect happens.
You can, actually, reduce these two lines to one:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
It's sufficient to write
RewriteCond %{REQUEST_FILENAME} !-f
Since the -f
test checks files and directories. If this still fails to produce your expected results, inspect PATH_INFO
and ORIG_PATH_INFO
in $_SERVER
if they're actually present.
Upvotes: 2