Solved

Rewrite non www

Posted on 2013-01-16
2
260 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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