remove index.php not working with my live server i

2019-05-27 02:08发布

问题:

remove index.php not working with my live server

it's work in my local server

I have Tried Below code

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

It's work in local wamp server but not in live server

Config.php detail

$config['base_url'] = 'http://ec2-174-129-44-226.compute-1.amazonaws.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['url_suffix'] = '';
$config['language'] = 'english';

回答1:

I've posted this answer dozens of time (2) there is a link in comments to a question simmilar to yours.

Please go to config/config.php and find this variable

$config['index_page'] = 'index.php' make sure it looks like this $config['index_page'] = '';

in the same file find $config['base_url'] = ''; make sure it looks like this

$config['base_url'] = 'http://ec2-174-129-44-226.compute-1.amazonaws.com/';

Also in core folder (where system, application is) create .htaccess file and make sure it looks like this

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [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>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>


回答2:

You can change your .htaccess like this

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

and change the value of "AllowOverride None" on /etc/httpd/conf/httpd.conf (if you use AMI Linux)

into "AllowOverride All"

after that restart your apache with command like this:

sudo service httpd restart


回答3:

<?xml version="1.0"?>
<configuration>
    <system.webServer> 
        <rewrite>
             <rules>
                 <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>