htaccess 301 Redirect Duplicate Inner Page URL's

htaccess 301 Redirect Duplicate Inner Page URLs

Posted on January 9, 2015 · Posted in Search Engine Optimisation, Web Design · BY: Amir Farid

Its very easy and common to get htaccess code to 301 redirect the duplicate home page URLs that may exist for your website home page. We looked at how to achieve that in an earlier post titled non-www to www. Googles Matt Cutts also has a good article here about that issue.

However trawling though the net or fiddling about with htacces codes to resolve the duplicate inner page URLs you may have is a much different matter. WordPress and many other CMS’s handle this easily without any intervention required from the user.

If however you have a static HTML site and/or a PHP based site then this may not be so easy. You may have fixed your duplicate home page URL’s but you will still have inner page duplicate URL’s like so:

  • www.example.com/innerpage/
  • www.example.com/innerpage/index.php
  • www.example.com/innerpage/index.html

To htaccess 301 redirect duplicate inner page URLs you have to be careful. Inadvertently adding the wrong code to your htaccess may give you a 404 page not found error for that page or worse for the whole of your site.

Luckily, its fairly simple to add code to the htaccess file. To htaccess 301 redirect duplicate inner page URLs you simply need to pop this code into your htaccess file. We would recommend adding this below the non-www to www code as per our earlier post:


RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.(php|html?)[#?]?
RewriteRule ^(([^/]+/)*)index\.(php|html?)$ http://example.com/$1 [R=301,L]

The first line of that code gives the parameters that need to be looked for. So in this case we are looking for index.html and index.php. You could of-course replicate this for inner-pages that are called innerpage.html and/or innerpage.php or any other variation that you could think of. To keep it simple we have used the index example.

Now all you would need to do is pop that into your htaccess file with the code referenced in the earlier non-www to www post and hey presto all you duplicate inner page URL’s will disappear. This will now leave you with one simple url that looks like:

www.example.com/innerpage/

Notice the / the URL’s will be appended with that and you will no longer have the index.html/php referenced. this is good for static HTML and PHP based websites.

Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr

Amir Farid

Creative SEO Director at Umbrella Interactive Ltd

Amir Farid is the Creative SEO Director of Umbrella Interactive Ltd. Based in Rochdale, Greater Manchester, Umbrella Interactive provides online and digital media solutions to SME’s and start-up businesses. Umbrella Brands include Umbrella Host, SEO Umbrella and Umbrella Web Studio. You Can find him on Google+

Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr

@UmbrellaWebStud

We are a full service #DigitalAgency based in #Rochdale, Lancashire specialising in #WebDesign, #MagentoDevelopment, #SEO and #PPC

RT @mashable: Heroic delivery man brings pizza to ‘hangry’ stranded train passengers https://t.co/y175m7vXeE https://t.co/Sp6uaXpnpZ – 2 weeks ago
Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr

Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr

Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr

Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr

Amir Farid
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr
  • Google+
  • Facebook
  • Pinterest
  • Twitter
  • Delicious
  • reddit
  • LinkedIn
  • StumbleUpon
  • Tumblr