Is this .htaccess file correct?

Hi, I wanted to redirect something like example.com to www.example.com, using 301 redirect in cPanel.

But I think I’ve made some mistakes editing the .htaccess file, and unfortunately didn’t back up before editing. Can you tell me help me to correct any errors in this .htaccess file?

# Use PHP5 as default
# AddHandler application/x-httpd-php5 .php .php4 .php3 .phtml

RewriteEngine on

RewriteRule ^test\/$ "http\:\/\/www\.profesornativo\.com\/test\.htm" [R=301,L]
RewriteRule ^test$ "http\:\/\/www\.profesornativo\.com\/test\.htm" [R=301,L]

#RewriteCond %{REQUEST_URI} test
#RewriteRule ^(.*)$  http://www.profesornativo.com/test.htm [R,L]  

RewriteEngine On
RewriteCond %{HTTP_HOST}  ^profesornativo.com [nocase]
RewriteRule ^(.*)         http://www.profesornativo.com/$1 [last,redirect=301]

RewriteCond %{HTTP_HOST} ^nativeenglishteacher.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.nativeenglishteacher.com$
RewriteRule ^/?$ "http\:\/\/www\.profesornativo\.com" [R=301,L]

RewriteCond %{HTTP_HOST} ^profesornativoingles.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.profesornativoingles.com$
RewriteRule ^/?$ "http\:\/\/www\.profesornativo\.com" [R=301,L]



<Files 403.shtml>
order allow,deny
allow from all
</Files>



RewriteCond %{HTTP_HOST} ^profesor\-nativo\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.profesor\-nativo\.com$
RewriteRule ^/?$ "http\:\/\/www\.profesornativo\.com" [R=301,L]

RewriteCond %{HTTP_HOST} ^profesor\-nativo\-ingles\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.profesor\-nativo\-ingles\.com$
RewriteRule ^/?$ "http\:\/\/www\.profesornativo\.com" [R=301,L]

RewriteCond %{HTTP_HOST} ^profesor\-nativo\.es$ [OR]
RewriteCond %{HTTP_HOST} ^www\.profesor\-nativo\.es$
RewriteRule ^/?$ "http\:\/\/www\.profesornativo\.com\/" [R=301,L]

Thanks.

To redirect to www all you need is:

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

Thanks for the quick reply! Ok, I used that code in my .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^profesornativo\.com
RewriteRule ^(.*)$ http://www.profesornativo.com/$1 [R=permanent,L

But I think it still isn’t working. The name of my file is htaccess-bak There was no .htaccess so I created one. Should I delete it and rename the .htaccess-bak file to .htacccess? Could this be why I’m having issues?

I should say do! Apache is looking for a file named .htaccess. not .htaccess-bak

Yep! That was it. Now I have only one file: .htaccess that contains all the code, and it works fine! Thanks for your help!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.