Reputation: 1
I've got a website that use a front controller that redirect traffic to certain files so I can employ SEO friendly URLs however there are some static pages on the site which I don't want traffic directed away from:
I currently have the following .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.exmple.com/$1 [L,R=301]
ErrorDocument 404 /controller.php
which seems to work fine:
www.example.com
;controller.php
to handle;www.example.com/about_us.php
still works;The problems is that it still reports a 404 error even though the page is still sent and displayed correctly - it doesn't look any different to the end user but its messing up my SEO with Google as the Google bot sees the 404 and assumes there's nothing else there.
Is there any way I can simply redirect all traffic apart from a list of certain pages or is there a more elegant solution?
Any help, thoughts, comments, etc. would be most welcome
Upvotes: 0
Views: 3990
Reputation: 19380
RewriteEngine On
ErrorDocument 404 /controller.php
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
You should route through index.php... otherwise line below should work instead of upper one.
RewriteRule .* $0 [PT]
Upvotes: 1