0

I have a website created with CodeIgniter, and although the URL Rewriting is working on my local installation (WAMP), it fails on my distant server.

The CI framework is installed in the "/dev" folder.

Here's the error when I try to access a controller using the following URL : http://www.mywebsite.com/dev/controller

Not Found

The requested URL /dev/index.php/controller/ was not found on this server.

I've tried every combination of .htaccess and config.php, but I can't figure out what's wrong.

However, http://www.mywebsite.com/dev/ works just fine.

Here's the .htaccess file :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

And the application/config/config.php file :

$config['base_url']     = '/dev/'; # I tried to put the whole path, didn't work either
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING'; # I tried every possibility, none of them work
$config['url_suffix'] = '';

What's really weird is that this exact configuration used to work on another server, I moved my code today and it doesn't work now...

Any idea ?

2 Answers 2

1

You're not using a query string in your rewrite rules, you're using path info. Try changing the uri protocol to:

$config['uri_protocol'] = 'PATH_INFO';

And if that still doesn't work, try changing your rules to append a query string instead:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?$0 [PT,L]
#                       ^------ a "?" here instead of "/"

And make sure the htaccess file is in the dev directory.

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

1 Comment

Setting the URI protocol to PATH_INFO didn't work, however your second solution proved to be effective. A functional answer in less than 5 minutes, God do I love Stackoverflow. Thanks !
0

try it

RewriteEngine On
RewriteBase /your_project_name/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

and bingo

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.