Solved

Rewrite non www

Posted on 2013-01-16
2
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Website being blocked? 3 146
Why Xampp showing MySQL as Maria DB on Welcome Page ? 8 132
Tomcat on Windows.  URL with {curly braces} fails. 1 265
maybe no no httpd.conf 6 88
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…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

759 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