Correct linking to the /index of a site and subfolders: what's the best practice? link to: domain.com/ or domain.com/index.html ?
-
Dear all,
starting with my .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.inlinear.com$ [NC]
RewriteRule ^(.*)$ http://inlinear.com/$1 [R=301,L]RewriteCond %{THE_REQUEST} ^./index.html
RewriteRule ^(.)index.html$ http://inlinear.com/ [R=301,L]1. I redirect all URL-requests with www. to the non www-version...
2. all requests with "index.html" will be redirected to "domain.com/"My questions are:
A) When linking from a page to my frontpage (home) the best practice is?: "http://domain.com/" the best and NOT: "http://domain.com/index.php"
B) When linking to the index of a subfolder "http://domain.com/products/index.php" I should link also to: "http://domain.com/products/" and not put also the index.php..., right?
C) When I define the canonical ULR, should I also define it just: "http://domain.com/products/" or in this case I should link to the definite file: "http://domain.com/products**/index.php**"
Is A) B) the best practice? and C) ?
Thanks for all replies!
Holger -
I think you have it correct there. I always like to end in a slash for index pages
http://inlinear.com/ - this is your home index page
http://inlinear.com/products/ - this is your index page for the /products/ folder/group
http://inlinear.com/products/page.php - this is a page within the /products/folder/group.
Hardly anyone ever sets up index web pages like index.php or index.htm anymore, they are really not needed as they just make the URL longer. End in the slash and make sure that you are consistent with ending with that slash (vs dropping it off) when you link to your index pages.
You would need to test the script you mention that rewrites the URL. It looks like it is making sure that the index page ends in a slash, but I could be wrong.
Side story - I have had a CMS that uses http://inlinear.com/products as the index page for http://inlinear.com/products/ and this creates all kinds of issues
-
Most people are used to not having an index page and the URL simply ending in a slash. So even if you had a non slashed version as your index page, people would link to the slash and then you have to setup 301s to fix that. Otherwise you end up with all kinds of duplicate page issues.
-
I know Google Analytics looks at the slashes to group your content into reports.
So the example index page of http://inlinear.com/products
would NOT be included in reports with all the pages in the /products/ group
e.g. http://inlinear.com/products/page.php
http://inlinear.com/products/anotherpage.php
as /products is not "within" /products/ You then have a report on /products/ that leaves out the index page and this is normally your most important page!
Good luck!
-
-
Thank you, but in practice how does it work without file-extension?
As I understood its fine if I put the following link to link on my homepage-index:
http://inlinear.com/ <--- without anything...
As well when I link to the products page:
http://inlinear.com/products/ <--- again without anything (index.php)
But in case of a specific page for example in the products-folder:
http://inlinear.com/products/my-product-1.php <--- how can I live without extension?
I googled and found this .htaccess code. Seems it takes away .php and ads a "/"... is this the best practice?:
Options +FollowSymLinks -MultiViews
Turn mod_rewrite on
RewriteEngine On
RewriteBase /Adding a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule . %{REQUEST_URI}/ [L,R=301]RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [L]Is this what you mean?
-
Best practice for all three cases is to never use the file extensions. You should never link to the file extension names, and make sure in your htaccess file that you dont use the file extensions for any reason moving forward. Why?
1. Lets say you decide to re-do your site and it goes from PHP to another language like ASP or something. You would have to redirect your entire site with file extensions and would shoot yourself in the foot with SEO, traffic and anything else. By not using file extensions, you give yourself the flexibility down the road and you can maintain a constant url structure.
2. Indexing may or may not use the file extensions depending on your htaccess/server settings. You would then essentially be running into duplicate content pages and issues, and thereby negatively affecting your site. Plus, it will dilute your individual page authority.
As a side note, just be consistent with your internal linking. Whether you use relative links or not - some discussion can be had around that. But pick a route and go with it, just as long as you dont use the file extensions
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Spammers created bad links to old hacked domain, now redirected to our new domain. Advice?
My client had an old site hacked (let's call it "myolddomain.com") and the hackers created many links in other hacked sites with links such as http://myolddomain.com/styless.asp?jordan-12-taxi-kids-cheap-T8927.html The old myolddomain.com site was redirected to a different new site since then, but we still see over a thousand spam links showing up in the new site's Search Console 404 crawl errors report. Also, using the links: operator in google search, we see many results of spam links. Should we be worried about these bad links pointing to our old site and redirecting to 404s on the new site? What is the best recommendation to clean them up? Ignore? 410s? Other? I'm seeing conflicting advice out there. The old site is hosted by the client's previous web developer who doesn't want to clean anything up on their end without an ongoing hosting contract. So beyond turning redirects on or off, the client doesn't want to pay for any additional hosting. So we don't have much control over anything related to "myolddomain.com". 😞 Thanks in advance for any assistance!
Technical SEO | | usDragons0 -
Internal links best practices
In looking at the inbound links to a client’s Home page, I see that the link from each page of the website back to the Home page is an image, and the ALT text is “Home.” I have a few questions about this, and would appreciate help understanding best practices: --Does it matter that the link back to the Home page is an image (presumably the client’s logo)? -- If we keep the image link, wouldn’t it be better to use “client’s company name” as ALT text rather than “Home”? --Should I recommend using an HTML link back to the Home page, and using the company name as anchor text? (I don't think it's relevant, but the site is built in Drupal.) Thanks!
Technical SEO | | jrae0 -
Linking out to authoritive sites from my ecommerce site
Good afternoon SEOmoz community. I was looking for a specific answer or advice or opinion about linking out to other sites. My Site www.tacticalbootstore.com has been undergoing a complete content rewrite. In the process we have been told and read where it can be good to link out to other authoritive sites. One of the pages we have rewritten is here. http://www.tacticalbootstore.com/belleville-boots-sizing-chart-a-97.html We have not added the graphics yet as they are being built now. This is just an informational page about sizing of a particular manufacturers boots. Once you get to the bottom of the text we have added a link to the actual manufacturers page. Is this helpful for us in the SERPS or not? Thank you for your time. Chris
Technical SEO | | scamper0 -
Duplicate Content - What's the best bad idea?
Hi all, I have 1000s of products where the product description is very technical and extremely hard to rewrite or create an unique one. I'll probably will have to use the contend provided by the brands, which can already be found in dozens of other sites. My options are: Use the Google on/off tags "don't index
Technical SEO | | Carlos-R
" Put the content in an image Are there any other options? We'd always write our own unique copy to go with the technical bit. Cheers0 -
Merging multiple sites and contacting linking domains
This is strictly academic but I am having a friendly debate and I am hoping you guys could help me. If I decided that I wanted to merge several websites into a single new URL doing everything I am supposed to (page to page 301 redirects, etc), will I still need to reach out to those important websites that link to my different sites to have them change the links and anchor text to point to the new site? I know that 90% of the link juice is supposed to transfer and that you are SUPPOSED to contact linking domains, but is it really worth it, especially if there are literally hundreds of sites to contact?
Technical SEO | | Mike_Davis0 -
Best way to create a shareable dynamic infographic - Embed / Iframe / other?
Hi all, After searching around, there doesn't seem to be any clear agreement in the SEO community of the best way to implement a shareable dynamic infographic for other people to put into their site. i.e. That will pass credit for the links to the original site. Consider the following example for the web application that we are putting the finishing touches on: The underlying site has a number of content pages that we want to rank for. We have created a number of infogrpahics showing data overlayed on top of a google map. The data continuously changes and there are javascript files that have to load in order to achieve the interactivity. There is one infographic per page on our site and there is a link at the bottom of the infographic that deep links back to each specific page on our site. What is the ideal way to implement this infographic so that the maximum SEO value is passed back to our site through the links? In our development version we have copied the youtube approach implemented this as an iframe. e.g. <iframe height="360" width="640" src="http://www.tbd.com/embed/golf" frameborder="0"></iframe>. The link at the bottom of that then links to http://www.tbd.com/golf This is the same approach that Youtube uses, however I'm nervous that the value of the link wont pass from the sites that are using the infographic. Should we do this as an embed object instead, or some other method? Thanks in advance for your help. James
Technical SEO | | jtriggs0 -
Way to find how many sites within a given set link to a specific site?
Hi, Does anyone have an idea on how to determine how many sites within a list of 50 sites link to a specific site? Thanks!
Technical SEO | | SparkplugDigital0 -
I have a site that has both http:// and https:// versions indexed, e.g. https://www.homepage.com/ and http://www.homepage.com/. How do I de-index the https// versions without losing the link juice that is going to the https://homepage.com/ pages?
I can't 301 https// to http:// since there are some form pages that need to be https:// The site has 20,000 + pages so individually 301ing each page would be a nightmare. Any suggestions would be greatly appreciated.
Technical SEO | | fthead90