[英]Rewriting .htaccess to remove index.php with alias url on codeigniter
[英]url rewriting htaccess , codeigniter only load my index page
几个小时以来,我一直困扰着这个问题,如果有人可以帮助我,那将真的很棒,所有内容都在标题codeigniter中,即使认为URL发生了变化并且调用了我的函数,也仅加载了我的索引页。 我激活了mod_rewrite并设置了我的config变量($ 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]
希望能帮助到你。
打开config.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 FILE中放入以下代码
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>
config.php并执行以下替换
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.