Page 1 of 1

Need help with a PHP redirect code

Posted: Tue Aug 24, 2010 9:44 pm
by detailxperts
I have a website where I want to redirect a page to a link that has the file extension removed. For example, the page I have is named "franchise.php" and I want the search engines that rank our site to be redirected to just "franchise" (without the .php).

I placed the following code in my .htaccess file and it still does not seem to work. I have tried a few different variants of this code, but nothing seems to work right.

RewriteEngine on

RewriteCond %{THE_REQUEST} ^http://www.detailxperts.net/[A-Z]{3,9}\ /([^.]+\.)+php?\ HTTP
RewriteRule (.+)\.php?$ http://www.detailxperts.net/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^http://www.detailxperts.net/franchise\.php$ http://www.detailxperts.net/franchise [R=301,L]



I would appreciate any help to figure out what is going wrong here.

Re: Need help with a PHP redirect code

Posted: Wed Aug 25, 2010 2:22 am
by amargharat
Just make following changes, for one line

Previous code

RewriteRule ^http://www.detailxperts.net/franchise\.php$ http://www.detailxperts.net/franchise [R=301,L]

New Code

RewriteRule ^http://www.detailxperts.net/franchise.php$ http://www.detailxperts.net/franchise [R=301,L]

Re: Need help with a PHP redirect code

Posted: Wed Aug 25, 2010 10:22 pm
by detailxperts
Thank you for your help...

Unfortunately, this still hasn't fixed the issue of getting our Search engine rankings to see our page(s) with the removed extension versus them focusing on the page with extensions.

I'm at wit's end now trying to figure out what is going wrong here...