Welcome Guest, Not a member yet? Register   Sign In
301 redirect, htaccess problem
#1

[eluser]ehicks727[/eluser]
I think I got myself into a mess here. I changed my site from using .php to no extension. This was a necessary move/change.

I have about 4,000 pages in my site.

The problem with this is that Google now has 4,000 incorrectly indexed pages and is going to penalize my rankings if I don't fix this somehow.

I thought I came up with a plan to redirect all the .php to no extension, but it backfired on me.

I put this into my .htaccess file

Code:
redirectMatch 301 ^/(.*)\.php$ http://www.example.com/$1

Well, it worked, except that it's now redirecting my index.php to index which is bombing my whole system.

Any ideas? Ideally, I'd like to redirect everything with .php to no extension except the index.php file.

Here's my existing .htaccess
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|img|robots\.txt|css)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
Options -Indexes
DirectoryIndex index.php

Any regex gurus out there?
#2

[eluser]Pascal Kriete[/eluser]
Going out on a whim here, but a negative lookahead might work:
Code:
redirectMatch 301 ^/(?!index)(.*)\.php$ http://www.example.com/$1
If that does work, make sure you don't have something like indexthing2.php, since that would match as well.




Theme © iAndrew 2016 - Forum software by © MyBB