I have seen other articles on the same issue. But none of the answers have solved my problem.
I am not using xampp or wamp but have setup php mysql apache seperately. Also I am using my own local domain for instance mytestsite.com.
My .htaccess file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /TestCI/
# Canonicalize Codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(HomeController(/index)?|index(.php|html?)?)/?$ / [R=301,L]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [R=301,L]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|TestCI) [NC]
RewriteRule ^(.*)$ http://www.mytestsite.com/$1 [R=301,L]
# Checks to see if the user is attempting to access a valid file,
# such as an image or css document, if this isn't true it sends the
# request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
I have also made following changes in config.php
$config['base_url'] = 'http://mytestsite.com/TestCI/';
$config['index_page'] = '';
$config['uri_protocol'] = 'PATH_INFO'; //AUTO
I have also made following changes in apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
But when i try to access
http://mytestsite.com/TestCI/HomeController/
its showing 404 error but works correctly when using
http://mytestsite.com/TestCI/index.php/HomeController/
I have looked into several similar questions that have been reported solved, but none of the answers have worked for me. Is there anything else that should be done to remove index.php
from the url. Kindly respond back. Help highly appreciated.
4
Answers
Thankyou for helping me... Problem is solved.
I made the following changes in my apache2.conf file
Also I removed the RewriteBase parameter in .htaccess file which is where the actual pbm was.
My current .htaccess file looks like
I have also made changes in config.php where i changed $config['base_url'] to codeigniter root path
Replace the following line of code in your
.htaccess
fileJust put this code in your .htaccess :
It may be the htaccess isn’t being used.
Put a sytax error in the file. (Append something like hdtbf to the file)
If that doesn’t give a 500 error you need to turn
allow override all
In your main Apache config
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride