我想从我的Codeigniter和Bonfire项目网址中删除/public/index.php
..
我当前的网址:http://localhost/public/index.php/page
所需网址:http://localhost/page
但我希望链接,图像和机器人的路径完好无损!怎么做到这一点?使用.htaccess的任何好资源?
答案 0 :(得分:1)
尝试阅读CodeIgniter URLs,小节'删除index.php文件':
<。>在.htaccess 中RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
在config.php中:
$config['index_page'] = '';
答案 1 :(得分:1)
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]
#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]
这在我的最后工作正常
答案 2 :(得分:1)
我认为你必须采取以下步骤:
将.htaccess文件从应用程序转移到根目录
删除/评论旧文件中的旧代码(使用#)和代码下面的代码
上的RewriteEngine
RewriteBase /
RewriteCond%{REQUEST_FILENAME}! - f RewriteCond%{REQUEST_FILENAME}!-d RewriteRule。* index.php?/ $ 0 [PT,L] RewriteRule ^ /?ajax /(.*)$ ajax.php?$ 1 [NC,QSA,L]
从$ config ['index_page']的配置文件中删除index.php,如下面$ config ['index_page'] ='';
然后从appache
它应该适合你。
答案 3 :(得分:0)
您将.htaccess文件从我想到的应用程序复制到您的basedir。
或者将新的.htaccess添加到您的基础。
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]