View Single Post
  #9 (permalink)  
Old 05-08-2008, 09:50 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,782
wige RepRank 4wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: 301 redirect problem?

ashishdabas, I don't think your senior understood the situation you were describing. When I visit your site, I can view the same content at both the / and /index.php variations. This is duplicate content caused by canonicalization, which is where the server uses the same file to respond to requests for different URLs. In your case, this would not cause an infinite loop, since there is no pre-existing redirection in the opposite way.

digitalpimp, you would need to add a second parameter to compensate for query strings.

Code:
Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index\.php$
RewriteRule ^(.*)index.php$ http://www.myspacelayoutspimp.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.php?
 RewriteRule ^/(.*)index.php(.*)$ http://www.myspacelayoutspimp.com/$1?$2 [R=301,L]
A few notes:
  • I added a $ to signify the end of the request string to the first conditional. This will prevent the first rule from being processed if there is a query string.
  • I added a slash to the beginning of the second rule. This should allow the rule to work with the root index as well as subfolders. You might need to test this to make sure it doesn't add an extra slash.
__________________
The best way to learn anything, is to question everything.
Reply With Quote