【发布时间】:2015-04-25 22:36:46
【问题描述】:
我正在尝试从我的 codeigniter 应用程序的 URL 中删除 index.php。
为此,我这样编写 .htaccess 文件:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
# RewriteBase /projectname/
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php [PT]
它在 xx.xx.xx.xxx 服务器和 mydomain.com 中运行。在这里,我尝试将相同的副本复制到另一台服务器 yy.yy.yy.yyy。在这种情况下,重写 URL 不起作用。如果我使用'yy.yy.yy.yyy/index.php/login',它工作正常。但是“yy.yy.yy.yyy/login”,它会抛出“在此服务器上找不到请求的 URL /projectname/login。”错误。
【问题讨论】:
标签: php .htaccess codeigniter rewrite