我如何在中间的某个地方移除codeigniter中每条路径中突出的"index.php"
?我想要干净的非index.php-fied URLs
发布于 2009-09-18 15:53:45
如果您使用的是Apache,请在您的web根目录中放置一个包含以下内容的.htaccess文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|[Javascript / CSS / Image root Folder name(s)]|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
另一个很好的版本位于这里:
发布于 2011-10-28 22:53:30
我在移除index.php时遇到了一些大问题。作为一般规则,下面的.htaccess已经在几个服务器上进行了测试,通常可以正常工作:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>
如果你没有任何运气,那么下一步就是调整你的配置文件。尝试一些其他URI协议,例如
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
$config['uri_protocol'] = 'ORIG_PATH_INFO';
如果您仍然没有任何运气,尝试更改重写规则,以包括您的子文件夹。如果您在开发服务器上使用临时URL,这通常是一个问题:
RewriteRule ^(.*)$ /subofolder1/subfolder2/index.php/$1 [L]
只要尝试一下这些选项,你就可以工作了。此外,请确保将索引文件设置为:
$config['index_page'] = '';
祝好运!
发布于 2012-09-08 18:47:30
将the.htaccess文件和index.php文件放在应用程序根目录中。(检查htaccess扩展是否正确,Bz htaccess.txt对我不起作用。)
并将以下规则添加到.htaccess文件中。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
然后在您的应用程序/config/config.php文件中找到以下行
$config['index_page'] = 'index.php';
将变量设置为空,如下所示。
$config['index_page'] = '';
就是这样,它对我很有效。
如果不起作用,请尝试将以下变量逐个替换为这些参数('AUTO‘、'PATH_INFO’、'QUERY_STRING‘、'REQUEST_URI’和'ORIG_PATH_INFO')
$config['uri_protocol'] = 'AUTO';
https://stackoverflow.com/questions/1445385
复制相似问题