如何删除" index.php?"来自HTACCESS

时间:2014-06-06 14:38:41

标签: php apache .htaccess mod-rewrite

我的网址是这样的:

www.site.com/index.php?/genero/aventura/av /

但我希望这是我的新网址:

site.com/genero/aventura/av /

我使用了以下代码:

<IfModule mod_rewrite.c>RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.site.com/$ [NC]
RewriteRule ^index.php\?/(.*)$ site.com/$1 [R=301,L]
</IfModule>

但只返回我:site.com/index.php?/ genero / wayntura / av /

这是我最新的&amp;完整版:

RewriteEngine on
#RewriteCond $1 !^(index\.php|ver_capitulo\.html|google3436eb8eea8b8d6e\.html|BingSiteAuth\.xml |portadas|public|mp3|css|favicon\.ico|js|plantilla|i|swf|plugins|player\.swf|robots\.txt)
RewriteCond $1 !^(index\.php|public|css|js|i|feed|portadas|robots\.txt|BingSiteAuth\.xml|plugins|i|mp3|favicon\.ico|pluginslist\.xml|google3436eb8eea8b8d6e\.html)
RewriteRule ^(.*)$ /index.php?/$1 [L]

#DirectoryIndex index.php
#RewriteCond %{THE_REQUEST} http://www.page.com/index\.php [NC]
#RewriteRule ^(.*?)index\.php$ http://page.com/$1 [L,R=301,NC,NE]

#DirectoryIndex index.php
#RewriteEngine On

感谢阅读。

1 个答案:

答案 0 :(得分:0)

用以下内容替换您的规则:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^(index\.php|public|css|js|i|feed|portadas|robots\.txt|BingSiteAuth\.xml|plugins|i|mp3|favicon\.ico|pluginslist\.xml|google3436eb8eea8b8d6e\.html)
RewriteRule ^(.*)$ /index.php?/$1 [L]