.htaccess simple redirection

Posted on 2011-10-06
Last Modified: 2012-05-12
Hi experts,

Here is a simple .htaccess question


My goal is to redirect to

I use that:

SetEnv PHP_VER 5
RewriteEngine on
Rewritecond %{HTTP_HOST} ^$
Rewriterule ^(.*)$1 [QSA,L,R=301]

It seems the htaccess is active because If I remove
SetEnv PHP_VER 5
I got php errors.

Troubles is : when I type in it does not redirect to www. !
What am I doing wrong ?


Question by:yarekGmail
    LVL 14

    Expert Comment

    I'm no expert at .htaccess, but check out the generator at Looks like the syntax is a little off.

    For a non-generator based solution, check out
    LVL 7

    Accepted Solution


    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^ [NC] 
    RewriteRule ^(.*)$$1 [L,R=301] 

    Open in new window


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
    Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    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

    21 Experts available now in Live!

    Get 1:1 Help Now