Need help with a PHP redirect code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
detailxperts
Forum Newbie
Posts: 2
Joined: Mon Aug 23, 2010 8:40 am

Need help with a PHP redirect code

Post 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.
amargharat
Forum Commoner
Posts: 82
Joined: Wed Sep 16, 2009 2:43 am
Location: Mumbai, India
Contact:

Re: Need help with a PHP redirect code

Post 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]
detailxperts
Forum Newbie
Posts: 2
Joined: Mon Aug 23, 2010 8:40 am

Re: Need help with a PHP redirect code

Post 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...
Post Reply