Remove index.php when access using ip address

2020-03-31 08:49发布

I uploaded codeigniter project on server.Removing index.php from URL is not working. I access it using IP address. like http://ip address/

Below is my htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

/etc/apache2/apache2.conf

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

I tried all possible solutions found on google. but not working for me.

4条回答
何必那么认真
2楼-- · 2020-03-31 09:33

Please follow some step:

  1. goto application/config/config.php : replace $config['index_page'] = 'index.php'; to $config['index_page'] = ''; and $config['uri_protocol'] = 'REQUEST_URI'; to $config['uri_protocol'] = 'AUTO';

  2. enable rewrite mode by
    sudo a2enmod rewrite then service apache2 restart

  3. if you'd like, you can use the following .htaccess file.

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

查看更多
男人必须洒脱
3楼-- · 2020-03-31 09:34

in httpd.conf, edit or delete "index.php":

<IfModule dir_module>
     DirectoryIndex index.php
</IfModule

Then in htaccess, add this:

Options -Indexes

查看更多
ら.Afraid
4楼-- · 2020-03-31 09:35

Add below code in .htaccess. Hope this work.

Options All -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
查看更多
beautiful°
5楼-- · 2020-03-31 09:42

Set your .htaccess as below

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

Then open /etc/httpd/conf/http.conf file and find <Directory "/var/www/html"> with in this find and set AllowOverride None to AllowOverride All.

查看更多
登录 后发表回答