We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6789
    • 11 Posts
    Having problems with 301 redirects fore some reason on this one site:

    I am getting a result like this:

    http://www.website.com/recruitment-services.html?q=page2.html instead of http://www.website.com/recruitment-services.html

    what did I do wrong? code below


    # For full documentation and other suggested options, please see
    # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions
    # including for unexpected logouts in multi-server/cloud environments
    # and especially for the first three commented out rules
    
    #php_flag register_globals Off
    #AddDefaultCharset utf-8
    #php_value date.timezone Europe/Moscow
    
    # For security reasons, Option followsymlinks cannot be overridden.
    #Options +FollowSymlinks
    Options +SymLinksIfOwnerMatch
    RewriteEngine On
    RewriteBase /
    
    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]
    
    # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.website\.com [NC]
    RewriteRule (.*) http://www.website.com/$1 [R=301,L]
    
    
    # Exclude /assets and /manager directories and images from rewrite rules
    RewriteRule ^(manager|assets)/*$ - [L]
    RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
    
    # For Friendly URLs
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
    
    
    RewriteCond %{QUERY_STRING}  ^$
    RewriteRule ^index\.php$ / [R=301,L]
    
    # Reduce server overhead by enabling output compression if supported.
    #php_flag zlib.output_compression On
    #php_value zlib.output_compression_level 5
    
    
    redirect 301 /page2.html http://www.website.com/recruitment-services.html
    
    AddOutputFilterByType DEFLATE text/html text/plain text/javascript
    
    
      • 4310
      • 2,310 Posts
      Try this before
      # For Friendly URLs
      RewriteRule ^page2.html$ recruitment-services.html [R=301,L]
        • 6789
        • 11 Posts
        Thanks, but that does not seem to work. I will try flushing cache though, just in case I am wrong.
          • 6789
          • 11 Posts
          Thanks, That solutions DID work. I will write rules for all old pages now 1-10

          But is it a permanent redirect and best for long-term SEO??

          Dave

            • 6789
            • 11 Posts
            sorry, I answered my own question. the [R=301,L] is the permanent redirect.

            Thanks for all of your help!!

            dave