Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Redirection - Collapse Seo To Index.php Or W/o Index.php


  • Please log in to reply
3 replies to this topic

#1 bobmeetin

bobmeetin

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 535 posts
  • Location:Colorado

Posted 01 December 2009 - 10:58 AM

I can set up the website so that home goes to www.mysite.com (how I have it now) or www.mysite.com/index.php. To avoid having both indexed by search engines so that you get different results is it better to go with index.php or not in navigation taking you home?

For SEO purposes how will you set up the .htaccess to follow suit? Point me to any relevant thread. Thx.



#2 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 01 December 2009 - 11:06 AM

It's doesn't really matter whether you use / or /index.php as the default home page address. Only that you're consistent in which use. Often this means redirecting the one you don't want to use to the address you do want to use.

How you do this in .htaccess is to use {THE_REQUEST} to look at the actual request being made by the user, as opposed to using something similar that only looks at the actual file being delivered by the server instead of the original request.

How to do this depends a good bit on what kind of addresses that include the /index.php file can show up and be valid. For instance, are there valid pages that might show up with a query string? (eg /index.php?var=value) Or will there never be a valid address using index.php with a variable?



#3 qwerty

qwerty

    HR 10

  • Moderator
  • 8,627 posts
  • Location:Somerville, MA

Posted 01 December 2009 - 11:06 AM

You're bound to get links pointing to the site at www.mysite.com, so I'd say www.mysite.com/index.php is the URL to avoid. Besides, if you ever change the file type of your pages and index.php becomes index.asp, then links to www.mysite.com/index.php would need to be changed and requests for it would need to be redirected. That wouldn't be the case if your home links just point to the domain's default location.

Here's the code I use in .htaccess. It also includes redirecting non-www URLs:
CODE
# Force requests for named index files to drop the index file filename, and force www:
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?|php)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(html?|php)$  http://www.url.com/$1  [R=301,L]
#
# Redirect non-www to www:
#
RewriteCond %{HTTP_HOST}   ^url\.com                     [NC]
RewriteRule  (.*)           http://www.url.com/$1        [R=301,L]


#4 bobmeetin

bobmeetin

    HR 6

  • Active Members
  • PipPipPipPipPipPip
  • 535 posts
  • Location:Colorado

Posted 01 December 2009 - 11:20 AM

QUOTE(qwerty @ Dec 1 2009, 09:06 AM) View Post
You're bound to get links pointing to the site at www.mysite.com, so I'd say www.mysite.com/index.php is the URL to avoid. Besides, if you ever change the file type of your pages and index.php becomes index.asp, then links to www.mysite.com/index.php would need to be changed and requests for it would need to be redirected. That wouldn't be the case if your home links just point to the domain's default location.

Here's the code I use in .htaccess. It also includes redirecting non-www URLs:
CODE
# Force requests for named index files to drop the index file filename, and force www:
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.(html?|php)(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*)index\.(html?|php)$  http://www.url.com/$1  [R=301,L]
#
# Redirect non-www to www:
#
RewriteCond %{HTTP_HOST}   ^url\.com                     [NC]
RewriteRule  (.*)           http://www.url.com/$1        [R=301,L]


I like this, tested already and works perfectly. This will go into my bag of tricks! Much thanks. I just wish I owned the domain, mysite.com.... Whip.gif




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

SPAM FREE FORUM!
 
If you are just registering to spam,
don't bother. You will be wasting your
time as your spam will never see the
light of day!