简体   繁体   中英

Removing index.php from url works on localhost and doesn't work online

I work on PHP project using codeigniter, I remove the index.php from URL locally, here is my .htaccess

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

When I upload the project online routes don't work at all, and I need to set index.php with plain url instead of the route!

for example instead of writing index I have to write index.php/product_management_controller/index

If I write index it doesn't work even if I update the route to include index.php !! That means the routes are also not working!

my current route is $route['index'] = "product_management_controller/index";

And here's a few things I've set in my config.php file:

$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

What is the solution!!

It works properly locally!!

Your server that your hosting on will need to allow .htaccess files, in your Apache config you will need to add:

AllowOverride All

to your Apache config. Then restart the Apache server.

You could also try

Options +FollowSymLinks -MultiViews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$1 [PT,L]

There is an documentation for removing index.php from url on codeigniter https://ellislab.com/codeigniter/user-guide/general/urls.html

By the way you are on godaddy shared server as per the comments and you don't have access to apache config file, but the good news is you don't need to worry rewrite mode is on for you by default. :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM