I want to rewrite requests to use index.php which is pretty standard and works.
The problem is that there are old and now invalid links which include the index.php and I want to redirect them to the root url of my site.
Potential duplicates include: Rewrite URL to index.php but avoid index.php in the URL, but the answers mentioned don't work for me.
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]
The url: http://domain.com/index.php/component/fsf/?view=faq, should be invalid and it should return a 404 error but because of my current rewrite rules, a site visitor will see the main page. I want to redirect this with a 301 to the main page so it can be dropped from search indexes. Any help would be appreciated.