Reputation: 8004
I am building a website using CodeIgniter PHP MVC Framework, but am having troubles with the routing of the site. I believe the problem is with the .htaccess file that I am using. I have my site at localhost/MyWebsite
and the home
controller (default) is calling the index
action correctly. However, when I try to go to any other Controller/Action (e.g. localhost/MyWebsite/register
) route I get a Forbidden Access error. I have a Register Controller with an index action but they were not being found or something. Here is the .htaccess file I am using.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
What do I need to do to make it so all requests are routed to the index.php file in CodeIgniter so that the proper Controllers and Actions can be called?
Upvotes: 0
Views: 1087
Reputation: 171
Are you allowing override within Apache for your .htaccess
file to take effect?
Paste the following code within httpd.conf
configuration file from Apache:
<Directory "PATH_TO_FRAMEWORK">
Option -Indexes +FollowSymLinks
AllowOverride all
Require all granted
</Directory>
Upvotes: 1
Reputation: 56
Make share that your files or folder are owned by www-data (whether owner user/group), check with: ls -l
assuming that your OS is ubuntu
if it's not correctly owned then execute:
sudo usermod -a -G your-username www-data
sudo chown your-username:www-data
Upvotes: 0