【发布时间】:2013-08-05 08:07:10
【问题描述】:
我无法从我的项目 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/(这不适用于上述代码)
以前的项目 url 是 http://Hostname/WCP/(这个适用于上述代码)
【问题讨论】:
-
您是否为每个项目创建了单独的虚拟主机?
-
抱歉,我不知道 vhost 这个词……听起来像虚拟主机……它如何解决上述问题?
-
配置中的base_url是什么?
-
("hostname/ODP/") 设置为base_url
-
尝试将
http://hostname/ODP/用作base_url,请尝试阅读此stackoverflow.com/questions/5155333/…
标签: php codeigniter redirect