获取"内部服务器错误"从URL中删除index.php

时间:2014-11-01 18:03:17

标签: php .htaccess codeigniter

我正在尝试从url中删除index.php部分。 这是我的.htaccess文件

RewriteEngine On
RewriteBase /faraztest

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

我也更改了config.php文件,但它仍然说"内部服务器错误"当我删除" /index.php /"后我把网址删除。请帮忙。

3 个答案:

答案 0 :(得分:1)

好吧,我完成了这个!

我的 config.php

$config['base_url']  = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

.htaccess 位于 /faraztest/.htacces

我的 .htaccess 文件是

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /faraztest
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
</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 /faraztest/index.php
</IfModule>
砰!砰!它有效!

我做错的两件事是我不包括

<IfModule mod_rewrite.c>
</IfModule>

以及ErrorDocument 404 /faraztest/index.php我没有给出正确的文件目的地。

答案 1 :(得分:0)

以下设置始终适用于我。如果不起作用,请检查浏览器中的Network标签,看看发生了什么。

<强>的config.php

$config['base_url'] = 'https://www.example.com/';
$config['index_page'] = '';

<强>的.htaccess

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteCond $1 !^(index\.php|web|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

答案 2 :(得分:0)

同样的问题发生在我身上,看起来你没有打开你的mod_rewrite模块,所以继续,在你的Apache设置中打开mod_rewrite模块,重启你的服务器就是这样。