从url中删除index.php

时间:2014-01-06 12:30:25

标签: php apache .htaccess

这就是我的.htaccess文件中的内容。 现在我想删除我的网址中的index.php。我该怎么做呢? 我已尝试过这个网站的几种可能性,但要么我得到500内部错误,要么根本没有任何变化。

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder                                                 it does run in ie. / becomes /shop/ 

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

2 个答案:

答案 0 :(得分:0)

以下代码将index.php重写为索引

RewriteEngine on
RewriteRule ^index index.php

答案 1 :(得分:0)

尝试这是否有效

Options +FollowSymLinks -Indexes
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

<IfModule mod_php5.c>
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>