3

I know there's a lot of questions and answers here but I'm really confused and I couldn't fix my problem yet. Please help!

I can easily access my controller via this url:

http://www.example.com/new/index.php/welcome

but I can't get it via this URL: http://www.example.com/new/welcome

I'm configuring my CodeIgniter site in a subdirectory "new" and on my server, my directory structure is:

/  
   htdocs
       new

/ (this is empty), htdocs(here is my directory named as "new" and new(this is the exact folder where I've my codeIgniter files. I'm confused here about "/" and "htdocs", I think this is the thing which I'm not able to handle because my domain example.com is pointing to htdocs i.e if I put index.php in htdocs, example.com will load index.php.

my .htaccess file in "new" directory is :

RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1

in config/config.php:

$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

I've tried $config['uri_protocol'] for "Auto", "REQUEST_URI" and "QUERY_STRING" etc.

With this configuration I'm able to remove index.php in my local host but I can't fix it on server. Please help!! Thanks in advance.

7
  • take a look to this page htaccessredirect.net Commented Sep 30, 2014 at 16:00
  • i forgot: $config['index_page'] = ''; dont leave blank spaces Commented Sep 30, 2014 at 16:01
  • there's no white space... mate please help me.. my server is fasthosts Commented Sep 30, 2014 at 16:06
  • try with my response Commented Sep 30, 2014 at 16:12
  • I've tried all steps as you described in your response but no effect. Commented Sep 30, 2014 at 16:18

7 Answers 7

2

this one worked for me

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]

make sure to remove index.php from appliation/config/config.php

$config['index_page'] = '';
Sign up to request clarification or add additional context in comments.

Comments

2

put this code in .htaccess file inside new directory

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

And dont forget to remove whitespace from:

$config['index_page'] = ' ';

3 Comments

no effect... same problem.. there's no whitespace in the above line specified by you.
whitespace between the quotations mate ' '
no there's no whitespaces. It is as : $config['index_page'] = '';
1

Try with this code in .htaccess :

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

7 Comments

sorry, no effect. same problem.
Try with : RewriteBase /new. I hope this will be work for you.
again no effect. Don't know how to fix it :\
Did you do any changes in your config file?
no, I just downloaded the codeIgniter, install it on my local PC, it works great, then I uploaded it to server and now I'm facing this issue.
|
1

Try either changing the

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

or changing the rewrite rule to use the query string instead:

RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?$1

Then setting the protocol to query string:

$config['uri_protocol'] = 'QUERY_STRING';`

Comments

1

If you say that it's working on localhost, then it might be a server problem. Check if the server mod_rewrite is on by writing phpinfo(); somewhere in your view code. If it's not on and you don't have permissions, contact your host admin.

Comments

1

This code works for me:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

And the config.php

$config['index_page'] = '';

Comments

0

Try adding ? after index.php in htaccess,

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

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.