URL重写htaccess,codeigniter只加载我的索引页面


url rewriting htaccess , codeigniter only load my index page

我从几个小时以来就一直遇到这个问题,如果有人可以帮助我,那就太好了,一切都在标题代码点火器中,只加载我的索引页面,即使认为 url 正在更改并且调用了我的函数。我激活了mod_rewrite,我的配置变量被设置($config['index_page'] = '';还有base_url())如果有人有想法!在这里,我向您展示我的.htaccess。

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

试试这个:

RewriteEngine on
RewriteCond $1 !^(index'.php|images|robots'.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

希望对您有所帮助。

打开配置.php并执行以下操作替换

$config['index_page'] = "index.php"

$config['index_page'] = ""

只需更换

$config['uri_protocol'] ="AUTO"

$config['uri_protocol'] = "REQUEST_URI"

并替换

$config['base_url'] = 'localhost:8888/EHA/';

$config['base_url'] = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';
$config['base_path'] = $_SERVER['DOCUMENT_ROOT'] . preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])) . '/';

并在HTACCESS文件中放置以下代码

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

你可以试试这个:如果 .htaccess 文件未添加。添加此 .htaccess 文件。

<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
    #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]
    #RewriteRule ^muser/([0-9]+) muser/index/$1
</IfModule>

配置.php并执行以下操作替换

$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;