ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Coming from an SEO perspective - htaccess question

February 06, 2012 6:57pm

Subscribe [5]
  • #1 / Feb 06, 2012 6:57pm

    colleen.simpson

    3 posts

    Hello fellow geeks,

    I am new to EE but have tons of experience in modx and wordpress cms. I am helping out on a website, that uses EE. Here’s the issues I am seeing:

    1. Duplicate content
    domain.com (as well as) domain.com/
    (This behavior follow suit for every page. Each page can be access using just the link or with a backslash extension)

    2. An oodle of 404 errors.
    Over 300 pages that were never given a 301.

    I don’t see anyplace to go and set a 301 (at the page level). Typically, you can go into the page - and set a 301. Or, use settings for duplicate content. (meaning only one way to access the page and you command that).

    Solution:

    It looks like I have to do both of these things (301 redirects and the one way to access a page) from an htaccess file. Is that the case?

    Please chime in!!

    Many thanks!

  • #2 / Feb 07, 2012 11:57am

    Shane Eckert

    7174 posts

    Hello Colleen,

    Welcome to the forums! We are glad to have you.

    If you wish to make your ExpressionEngine site SEO happy, especially for Google there area few changes to make in your htaccess file.

    You are going to either force inclusion or force exclusion of “www” and force inclusion or force exclusion of the trailing slash.

    The code for the .htaccess file looks like this.

    .htaccess
    
    Force inclusion of WWW
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.your_domain.com$
    RewriteRule ^(.*)$ <a href="http://www.your_domain.com/$1">http://www.your_domain.com/$1</a> [R=301]
    
    Force exclusion of WWW
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
    RewriteRule ^(.*)$ <a href="http://example.com/$1">http://example.com/$1</a> [R=301,L]
    
    Force inclusion of a trailing slash
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)/$
    RewriteRule ^(.*)$ <a href="http://www.domain.com/$1/">http://www.domain.com/$1/</a> [R=301,L]
    
    Force exclusion of a trailing slash
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(.*)$
    RewriteRule ^(.*)$ <a href="http://www.domain.com/$1">http://www.domain.com/$1</a> [R=301,L]

    I hope this helps.

    Is there anything else I can help you with?

    Cheers,

     

     

  • #3 / Feb 07, 2012 1:05pm

    colleen.simpson

    3 posts

    Thank for the info Shane!

    So, regarding the not found and 404 action I have going on….

    1. Where do I account for the 300+ 404 pages I have. Is this all done w/in htaccess?

    2. The website I am working on frequently “kills” pages. It would be great to have a plug in/module/ system for putting 301 in place for the non techies that work here. Is that an option or no - all w/in the htaccess?


    Gracias!

  • #4 / Feb 07, 2012 3:13pm

    Shane Eckert

    7174 posts

    Hello Colleen,

    We have documentation on handling 404’s and how to implement that site wide. Through this method ExpressionEngine will only display the 404 Template if the requested Template Group in the URL does not exist.

    There is a plugin or two that deal with 301, check Devot://ee. I think this will be helpful.

    I hope this helps. If you need any more information or have more questions, please let me know!

    Cheers,

  • #5 / Feb 18, 2012 3:08am

    cityzen

    83 posts

    Hi Colleen -

    I’ve actually written an extension called Detour: http://cityzen.com/addons/detour that does this through the CP.  I’m currently working on a Pro version which will be ready next week that will do redirects, allow wildcards, dates to start and end redirects, etc.  Hopefully that will help you.

    Mike

  • #6 / Feb 22, 2012 1:28pm

    Shane Eckert

    7174 posts

    Hey Mike,

    Thanks for the input! Excited to see, and suggest when necessary, the Pro version when it’s ready!

    Colleen - does this look like a solution you could use?

    Cheers,

  • #7 / Feb 22, 2012 1:57pm

    cityzen

    83 posts

    Hey Shane -

    Pro version actually came out yesterday.  You can check it out here: http://cityzen.com/addons/detour_pro and on Devot-ee here: http://devot-ee.com/add-ons/detour-pro

    Let me know if you have any questions.

    Mike

  • #8 / Feb 22, 2012 2:59pm

    Shane Eckert

    7174 posts

    Mike,

    Thanks for the update!

    Be sure to let Kyle know to add it to this FRUP this week.

    Thanks,

  • #9 / Aug 10, 2012 4:30am

    tlloyduk

    29 posts

    Hi all,

    Could I re-open this thread for a moment as I’m having problems with the trailing slash issue.

    I’m using EE 2.5.1 and my .htaccess looks like:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        # Removes index.php
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /en/index.php/$1 [L]
        # If 404s, "No Input File" or every URL returns the same thing
        # make it /index.php?/$1 above (add the question mark)
    </IfModule>

    If I add your suggested lines to exclude the trailing slash, e.g.:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        # Removes index.php
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
    
        # Force exclusion of trailing slash
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_URI} !(.*)$
        RewriteRule ^(.*)$ <a href="http://www.domain.com/$1">http://www.domain.com/$1</a> [R=301,L]
    
        RewriteRule ^(.*)$ /en/index.php/$1 [L]
        # If 404s, "No Input File" or every URL returns the same thing
        # make it /index.php?/$1 above (add the question mark)
    </IfModule>

    I get a 500 Internal Server Error on any sub pages apart from homepage whether I specify or don’t specify a trailing slash.

    Many thanks for your help - my SEO people are giving me grief about duplicate content everywhere!

    Perhaps one thing to note is I am using Bieber Multi-language plug-in as well, hence the /en/ in the .htaccess. And therefore my .htaccess file is in /var/www/domain.com/en rather than /var/www/domain.com

    Thanks,

    Tim

  • #10 / Aug 10, 2012 4:31pm

    Shane Eckert

    7174 posts

    Hey tlloyduk,

    A few things to consider. The Multi-Language plugin may not be compatible with that Add-on.

    Also, check the server logs for that 500 error, that’s where it will be and this will give us some more insight.

    We do not actually support the modifications to the .htacess file aside from removing index.php because each server handles requests differently.

    I think the log is going to be key.

    Thank you,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases