0

我无法从我的项目 URL 中删除 index.php。下面是我尝试过的代码。

对于托管在同一服务器上的另一个项目,以下相同的代码和配置设置正常工作

在 .htaccess 文件中

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|imgs)
RewriteRule ^(.*)$ index.php/$1 [L]  
RewriteRule ^media/images/([0-9]+)/([A-Za-z0-9-]+).jpg?$ imgs/$1  [T=image/jpeg,L]
<Files "index.php">
AcceptPathInfo On
</Files>

.htaccess 文件与应用程序文件夹平行放置在根文件夹下。

在 config.php 文件中

$config['uri_protocol'] = 'PATH_INFO';
(also tried same for all server global mentioned in config.php)

and

$config['index_page'] = '';

当前项目的 url 就像http://Hostname/ODP/(这个不适用于上面的代码)

以前的项目网址是http://Hostname/WCP/(这个适用于上述代码)

4

1 回答 1

1
Use following htaccess code to remove index.php from your codeigniter url
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]
于 2013-08-05T10:24:31.667 回答