无法从活动网站中的codeigniter网址中移除index.php
我需要从我的codeigniter网址中移除index.php。这是我在.htaccess文件代码:无法从活动网站中的codeigniter网址中移除index.php
RewriteEngine On
RewriteRule ^index.php/(.*)$ /$1 [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
和config.php文件修改:
$config['base_url'] = 'http://example.com/'
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
在我的本地工作的罚款。但在我的生活网站,它会产生一个404错误。
我可以通过index.php('http://example.com/index.php/Home')加载url,但'http://example.com/Home'生成404错误。为什么这只发生在现场?还有其他需要改变吗? 一两件事,它不是一个Apache服务器,我的网站发表在IIS
粘贴.htaccess文件
RewriteEngine On
#RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1
下面的代码,然后转到您的配置文件中的配置文件夹,删除索引。从
$config['index_page'] = '';
PHP的,如果你的网站是在子文件夹中,那么你必须后添加子文件夹名称“#RewriteBase /”
它不在子文件夹中。那么我需要包含RewriteBase? – geeth
是的,你确实需要添加 – interntseekho
我认为你是英里ssing
RewriteBase/
以下是完整的htaccess的应驻留在主项目文件夹。如果它位于子文件夹中,则必须编写rewritebase。
<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
请试试看,让我知道它的工作与否 –
尝试从第二行 – shashi
删除[R = 302,L]仅适用于现场?如果我从我的代码中删除它将重定向到我的仪表板在本地主机 – geeth
该网站发布在IIS – geeth