我知道这个问题已经被问过很多次了。但是,我仍然无法摆脱index.php网址。这阻止了我直接访问我的控制器。
我目前正在使用CodeIgniter 2.2.2
。
以下是我的.htaccess
文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
应用程序/配置:
// Find the below code
$config['uri_protocol'] = "AUTO"
// Replace it as
$config['uri_protocol'] = "REQUEST_URI"
任何的想法?在此先感谢您的时间。
终于解决了我的问题。我想与大家分享我的答案。我当前正在使用Mac,将.htaccess文件重命名为htaccess.txt,并在htaccess中包含以下代码:RewriteEngine On
#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 %{ENV:REDIRECT_STATUS} ^$
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
然后通过执行以下操作确保Apache正在读取htaccess.txt文件:
在您的httpd.conf上取消注释以下行
往里走多余/的httpd-default.conf文件并更改这一行代码:AccessFileName .htaccess
对AccessFileName htaccess.txt
重新启动Apache服务器
在您的配置中,请确保将“ base_url”留空(索引页仍然可以存在,没关系)。并且$ config ['uri_protocol'] ='REQUEST_URI';
希望这可以帮助其他人!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句