need help with htaccess file please

Posted on 2012-09-03
Last Modified: 2012-09-03
hi i am new to htaccess files. i would like to redirect the following urls


basicaly i would like all verions of the url to redirect over to

i have tried this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{HTTP_HOST} ^$
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$$1 [L,R=301]

but its not working. :(

can any one advise please?
Question by:helpchrisplz
    LVL 29

    Expert Comment

    by:Randy Downs
    Try this

    RewriteCond %{HTTP_HOST} !^\.com$ [NC]
    RewriteRule ^(.*)$$1 [R=301,L]
    LVL 58

    Expert Comment

    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{THE_REQUEST} ^.*/index.html
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    LVL 1

    Author Comment


    i try your example but it didn't work


    that works but

    are still available.
    LVL 58

    Accepted Solution

    Not great at rewrite rules but try instead

    RewriteEngine on
    RewriteBase /
    RewriteCond %{THE_REQUEST} ^.*\/index\.html\ HTTP/
    RewriteRule ^(.*)index\.html$ /$1 [R=301,L]
    RewriteCond %{http_host} ^$ [nc]
    RewriteRule ^(.*)$$1 [r=301,nc,L]
    LVL 1

    Author Closing Comment

    That's great thank you

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Suggested Solutions

    If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
    Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now