We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9995
    • 1,613 Posts
    I would like to remove .html from my Evo website.

    But when I do this I loose my google page ranking because google no longer can find the URL and the "new" url/page will be added to the google results mostly lower as the old page with .html

    So to solve this I need to remove the .html (mod_rewrite?) and make sure the .html redirects to without the .html
    I think this is possible with .htaccess

    Does anyone knows how to do this?

    This question has been answered by fourroses666. See the first response.

      Evolution user, I like the back-end speed and simplicity smiley
      • 20413
      • 2,877 Posts
      Google is fast. I have stoped doing 301 directs!

      // Personally I don't do 301 directs but let a search plugin on 404 suggest new address to the visitor
      or just set up the old address as a weblink.

      Google rank new pages super-fast and if the _content_ of the old page is changing so will the rankings too in a short time.
      http://forums.modx.com/thread/88953/friendly-urls-using-302-redirect-rather-than-301

      Anyway... In EVO system settings click "Use SEO Strict URLs" that should give a 404 on those pages. Then write a 404 plugin:
      In plugin config paste in
      &pg=Error Page;

      click somewhere and set the ID of your 404 doc.

      OnPageNotFound: CODE NOT TESTED!!
      $e = & $modx->Event;
      
      switch ($e->name) {
        case "OnPageNotFound":
          if(!$pg) $modx->sendErrorPage();
        else{
        
          //Parse out the requested page.
          $errorword = str_replace("/", " ", $_SERVER['REQUEST_URI']);
      
          if ($errorword != '') {
          
            //Find the .html
            $errorwordSuffix = ".html";
          
            //Remove the .html
            if(stristr($errorword,$errorwordSuffix)) {
              $errorword = str_replace($errorwordSuffix, " ", $errorword);
            }
          }
      
          //Redirect to the new page with a 301 header
              $modx->sendRedirect('http://www.YOURSITE.com/'.$errorword, 0, 'REDIRECT_HEADER', 'HTTP/1.1 301 Moved Permanently');
          exit;
        }
      
        break;
      
        default :
        return; // stop here
        break;
      }
      


      API:sendRedirect
      http://wiki.modxcms.com/index.php/API:sendRedirect

      Don't forget the canonical:
       <link rel="canonical" href="http://url/page">


      Further reading to stop this madness: https://blog.hubspot.com/blog/tabid/6307/bid/33926/7-Common-SEO-Myths-to-Throw-Out-the-Window-Immediately.aspx
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
      • discuss.answer
        • 9995
        • 1,613 Posts
        I forgot to place my answer, thanks for your help @mrhaw!

        I use this now:
        <link rel="canonical" href="[[if? &is=`[*id*]:is:1` &then=`[(site_url)]` &else=`[(site_url)][~[*id*]~]`]]" />


        and working .htaccess laugh
        Options +FollowSymLinks -MultiViews
        DirectorySlash Off
        
        RewriteCond %{SCRIPT_FILENAME}/ -d
        RewriteCond %{SCRIPT_FILENAME}.html !-f
        RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
        
        RewriteCond %{ENV:REDIRECT_STATUS} ^$
        RewriteRule ^(.+)\.html$ /$1 [R=301,L]
        
        RewriteCond %{SCRIPT_FILENAME}.html -f
        RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]




        Info:
        Use this above setting when you have always set on .html and want to remove that to get a shorter URL. So Google will keep your search ranking in order. (history of the page etc.)


          Evolution user, I like the back-end speed and simplicity smiley
          • 20413
          • 2,877 Posts
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 9995
            • 1,613 Posts
            yea pritty fast indexing indeed. smiley
            guess forums.modx is crawled pritty much!

            but I don't think it's that weird these combo of words give place #1

            "remove .html" = page 3 at the moment thats oké I think
            "modx .html" = page 1 and place "2" :-O


              Evolution user, I like the back-end speed and simplicity smiley
              • 9995
              • 1,613 Posts
              I have the feeling Google is watching and following us mrhaw smiley
                Evolution user, I like the back-end speed and simplicity smiley
                • 20413
                • 2,877 Posts
                Humans Account for Less Than 40% of Global Web Traffic http://mashable.com/2014/02/12/human-bot-web-traffic/

                SEO is valuable but to reach a Target Audience. You have to produce what they want. So that they share and talk about you.

                I searched for MODX because somebody mentioned it on a joomla forum back in 2008. smiley

                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                  • 9995
                  • 1,613 Posts
                  New htaccess Question:

                  I have build a new site. Some old URLs I'd like to add to my htaccess which redirects to the new paths/urls
                  I thought this could be done by adding the line(s):
                  Redirect /Test http://www.mydomain.nl/contact


                  When going to http://www.mydomain.nl/Test I get redirected to:

                  http://www.mydomain.nl/contact?q=Test

                  Anyone knows how to fix this (remove the ?q=Test) ?
                  Looks like it has to do with the Friendly URL rewrite..

                  My .htaccess file:

                  Options +FollowSymlinks
                  RewriteEngine On
                  RewriteBase /
                  
                  RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
                  RewriteRule .* - [F,L]
                  RewriteRule ^(manager|assets) - [L]
                  
                  # For Friendly URLs
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                  
                  Redirect /Test http://www.mydomain.nl/contact
                  [ed. note: fourroses666 last edited this post 9 years, 11 months ago.]
                    Evolution user, I like the back-end speed and simplicity smiley
                    • 21417
                    • 486 Posts
                    Hi fourroses666,

                    I think you need the redirect rule above the friendly url code.

                    And also perhaps slightly different redirect rules (I got these from the forum a long time ago).

                    Try a redirect rule like this...
                    RewriteRule ^Test$ http://www.mydomain.nl/contact [L,R=301]


                    or this...
                    RewriteCond %{REQUEST_URI} /Test$
                    RewriteRule (.*) /contact [S,L,R=301]


                    So your htaccess might look something like this...
                    Options +FollowSymlinks
                    RewriteEngine On
                    RewriteBase /
                    
                    RewriteRule ^Test$ http://www.mydomain.nl/contact [L,R=301]
                    #OR
                    #RewriteCond %{REQUEST_URI} /Test$
                    #RewriteRule (.*) /contact [S,L,R=301]
                    
                    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
                    RewriteRule .* - [F,L]
                    RewriteRule ^(manager|assets) - [L]
                     
                    # For Friendly URLs
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteCond %{REQUEST_FILENAME} !-d
                    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                    


                    Did that work? [ed. note: nickf08 last edited this post 9 years, 11 months ago.]
                      Web design Adelaide
                      http://gocreate.com.au
                      • 9995
                      • 1,613 Posts
                      Thanks!! they both work!

                      RewriteRule ^Test$ http://www.mydomain.nl/contact [L,R=301

                      You forgot the ]
                        Evolution user, I like the back-end speed and simplicity smiley