Mod rewrite Mod_Rewrite:将URL重写为index.php,但将index.php重定向到root

Mod rewrite Mod_Rewrite:将URL重写为index.php,但将index.php重定向到root,mod-rewrite,Mod Rewrite,我想重写请求以使用index.php,这是非常标准且有效的 问题是有旧的和现在无效的链接,其中包括index.php,我想将它们重定向到我网站的根url 潜在的重复项包括:,但提到的答案对我不适用 RewriteEngine on # This results in a redirect loop #Redirect 301 /index.php http://domain.com # This gets me a 500 error # RewriteCond %{THE_REQUEST}

我想重写请求以使用index.php,这是非常标准且有效的

问题是有旧的和现在无效的链接,其中包括index.php,我想将它们重定向到我网站的根url

潜在的重复项包括:,但提到的答案对我不适用

RewriteEngine on

# This results in a redirect loop
#Redirect 301 /index.php http://domain.com

# This gets me a 500 error
# RewriteCond %{THE_REQUEST} ^GET\ /index\.php/?([^ ]*)
# RewriteRule ^index\.php/?(.*) / [L,R=301]

# Push www traffic to base domain.  <<= Works
RewriteCond %{HTTP_HOST} !^domain.com$ [NC] 
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

# Final rewrite to include index.php   <<= Works
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /?([A-Za-z0-9_-]+)/?$ index.php?id=$1 [QSA,L]
url:,应该无效,并且应该返回404错误,但是由于我当前的重写规则,网站访问者将看到主页。我想用301将其重定向到主页,这样就可以从搜索索引中删除它。 任何帮助都将不胜感激。

将您的请求规则更改为


此外,它还重写了具体的示例[dbfront.com/?view=faq],没有引起任何进一步的问题。事实上,我希望URL中没有垃圾。
RewriteCond %{THE_REQUEST} ^GET\ /index\.php(/.*) [NC]
RewriteRule ^ /? [L,R=301]