We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31227
    • 198 Posts
    Hi every one, it has been a while since I posted, but I do come in once in a while to take a look whats going on.
    Now, I’ve got a tiny problem. I want to force a suffix to links. Example:
    www.domain.com/about-us –> www.domain.com/about-us.html and while at it, show a 301 redirect.
    I have managed to force a suffix, but than I get a 404 error if a link is typed without a suffix.

    The other thing is, I’d like to force all urls from 1 domain, to go to the other domain. Here is what I mean:
    www.domain.com/about-us-en.html -> www.domain.RU/about-us-en.html

    How do I go about to achieve this?

    .htaccess below:
    AddType application/x-httpd-php53 .php
    
    #MIME types
    #CharsetDisable On
    php_flag register_globals Off
    AddDefaultCharset UTF-8
    
    FileETag None 
    
    #Redirects
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    
    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]
    
    # For Friendly URLs
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    RewriteRule ^([^/]*)\.html$ index.php?q=$1 [L,QSA]
    
    #RewriteCond %{HTTP_HOST} ^viriko\.com
    #RewriteRule (.*) http://www.viriko.com/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^viriko\.ru
    RewriteRule (.*) http://www.viriko.ru/$1 [R=301,L]
    
    
    
    #RewriteRule home-ru\.html / [L,R=301]
    #RewriteRule ^index\.php$ / [L,R=301]
    #RewriteRule home-ru / [L,R=301]
    #RewriteRule home-ru/ / [L,R=301]
    
    # Exclude /assets and /manager directories and images from rewrite rules
    RewriteRule ^(manager|assets)/*$ - [L]
    RewriteRule \.(jpg|jpeg|png|gif|ico)$ - [L]
    
    
    #For servers that support output compression, you should pick up a bit of speed.
    php_flag zlib.output_compression On
    php_value zlib.output_compression_level 6
      Pure MODx sites
      Viriko.ru & Viriko.com - Multilingual and running on 1 MODx
      • 20725
      • 32 Posts
      I want to force a suffix to links. Example:
      www.domain.com/about-us –> www.domain.com/about-us.html and while at it, show a 301 redirect.
      I have managed to force a suffix, but than I get a 404 error if a link is typed without a suffix.
      How do I go about to achieve this?
      I believe .htaccess files are not and have never been designed to redirect from an arbitrarily selected page to another arbitrarily selected page. I believe there are only two things you can do:

      Step 1: Forget about your .htaccess page.

      Step 2: Create and get full acceptance for a page you name "about-us", and then once you do have that page (which is a bit of a challenge), you want to put a "longer, let’s say 5-second refresh tag" in the <head> section of that page, so it will redirect to "about-us.html", and in the 5-second window it will show pretty much anything you put on that page, including a "301 redirect" message.

      Alternative step 1: Use the .htaccess page to redirect all miscellaneous/erroneous URLs to your main page. This is the easiest part, which I’m not going to and shouldn’t explain.

      Alternative step 2: Not applicable.

      I’d like to force all urls from 1 domain, to go to the other domain. Here is what I mean:
      www.domain.com/about-us-en.html -> www.domain.RU/about-us-en.html
      How do I go about to achieve this?
      Step 1: Forget about your .htaccess file. I believe .htacess files have never been designed to point to some other domain.

      Step 2: Set up an identical site at domain.ru.

      Step 3: Just go to the hosting company of domain.ru and ask them to "park" domain.com for you. This will force all URLs extensions of domain.com to go to the identical URL extensions of domain.ru. NOTE: Sometimes, "park" or "parking" is not the right word, because some hosting companies call it differently. In that case, just tell them you want to "point" your domain.com to your domain.ru.

      Step 4: Change/redirect the name servers of domain.com to your server at domain.ru.
        Best regards,
        Mike

        MODx Revolution 2.0.7 and 2.0.8 powered by PHP 5.3.5 / Apache 2.2.17 / MySQL 5.0.7 on Shared hosting
        MS Vista and FF 3.6.15 / Many dot com web sites.
        Timezone: America/New_York
        • 33968
        • 863 Posts
        Step 2: Create and get full acceptance for a page you name "about-us", and then once you do have that page (which is a bit of a challenge), you want to put a "longer, let’s say 5-second refresh tag" in the <head> section of that page, so it will redirect to "about-us.html", and in the 5-second window it will show pretty much anything you put on that page, including a "301 redirect" message.
        Sorry mate but that’s an outdated practice and just bad advice from a usability and SEO perspective. Ask Google and the W3C. Do you enjoy watching those ’refresh’ pages waiting for the countdown to finish? I sure don’t. Using a proper server-side 301 will help to preserve ’link juice’ from your old links and help the new domain maintain search rankings.

        @vait: is there any reason why you want to actually lengthen your urls by adding the .html extension? Do a quick Google search and you’ll find most webmasters are trying to do the opposite. The cleaner the better in my opinion. The extension is not necessary so why complicate things smiley

        As for your domain forwarding requirement (.com -> .ru), you could contact your host as per mw11’s suggestion, but I’m under the impression that they would simply catch all urls and direct them to www.domain.ru instead of their equivalent pages. I’m no expert on .htaccess but you could try this:

        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^www.domain.com$[OR]
        RewriteCond %{HTTP_HOST} ^domain.com$
        RewriteRule ^(.*)$ http://www.domain.ru/$1 [R=301,L]
        


        You would of course need to ensure that your site exists at www.domain.ru, so whether that means moving your whole site to a new folder on your server and/or doing some DNS magic may depend on your hosting situation.

        Also, before you do anything I would recommend you read through Google’s Webmaster Guidelines on moving to a new domain. That’ll help to minimise any unwelcome surprises tongue