1

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!

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you, still does not work however. There's no PATH_INFO in $_SERVER, but there is ORIG_PATH_INFO which is /register
I've updated my $config['uri_protocol'] to use 'ORIG_PATH_INFO' - this works! Is this the best solution?
@dave Yes. Depending on the environment PHP runs (module, CGI, FastCGI), the actual PATH_INFO can be found in many an odd "alias" in $_SERVER.
0

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.