Solved

Rewrite non www

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

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
URL rewriting - LAMP 7 51
.htaccess rewrite url with querystring problem 13 113
Apache error.log 19 72
PHP_POST() error message 9 77
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 you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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