Solved

Rewrite non www

Posted on 2013-01-16
2
258 Views
Last Modified: 2013-01-17
I'm going to be adding a .com.au domain and is not working correctly

If you request mydomain.com.au it routes to www.mydomain.com
instead of www.mydomain.com.au

I added the "$" to terminate, is that not correct?

RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
RewriteRule ^/(.*)$ http://www.mydomain.com [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^mydomain.com.au$ [NC]
RewriteRule ^/(.*)$ http://www.mydomain.com.au [R=301,NC,L]
0
Comment
Question by:JRockFL
2 Comments
 
LVL 13

Accepted Solution

by:
LinuxGuru earned 500 total points
ID: 38786582
Try to use the following to redirect all request to www.

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

Open in new window


Cheers!!!
0
 
LVL 26

Expert Comment

by:arober11
ID: 38786622
For a start alter the pattern and conditions on your to rules to loose the leading / and the NC e.g.

RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule .* http://www.mydomain.com [R=301,L]

Open in new window


If still broke and assuming the rules above are in your httpd.conf  (not a .htaccess file), then stick a:

RewriteLog  /tmp/temp_rewrite_debug.log
RewriteLogLevel 9

in the same block and restart apache. Then tail the log, to see what's coming in, by way of a HTTP_HOST, and what the module makes of it.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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