Forum Moderators: phranque
Directory Redirected From My main domain: www.mymaindomain.com/directory
New domain: www.directory.com
Rewrite rule used in my main domain .htaccess file:
RewriteEngine on
RewriteRule ^directory/(.*) http://www.directory.com/$1 [R=301,L]
Now I am getting a non www url problem whenever I am browsing a subdirectory of my new domain i.e www.directory.com, suppose I want to browse a subdirectory like www.directory.com/subdirectory, I always lands in non www version i.e when i click a url to a sub directory it comes as directory.com/subdirectoryrather than www.directory.com/subdirectory and it is happening with all the subdirectories in this particular domain. Outside the subdirectory it is coming as www version but whenever i enter a subdirectory it automatically comes out in non www version.
Please help so that i get the www version of the whole domain.
[edited by: jdMorgan at 2:59 pm (utc) on May 25, 2008]
[edit reason] de-linked [/edit]
You may want to look into the details of how directory.com was set up on the server, and make sure that it was consistently defined as "www."
Be aware that mod_rewrite takes action "after the fact." You can rewrite and redirect all you want, but it is the links on your pages which "define" the URL. It wasn't clear what the directory.com links look like on your pages, but they should all be pointing to the "www" version.
Jim
And as stated above, set UseCanonicalName to "off" if the server name is defined as directory.com and not as www.directory.com.
If you do not have server config-file access, or if your control panel does not have the capabilities needed to properly configure www.directory.com, then you will have to contact your host to fix this problem.
The only way the address bar can change to directory.com after you click on a link to www.directory.com is because of an external redirect. This means that there is code or a directive on your server that is doing this. You can verify this by using the "Live HTTP Headers" add-on for Firefox/Mozilla browsers; Use it to examine your server response headers when requesting a www.directory.com URL. You will see a redirect response which sends the browser to directory.com after requesting www.directory.com. You must find the code or directive that is invoking that redirect and correct it.
Jim
Firstly I entered the main url i.e www.directory.com, here is the response i get,
sent Data
GET / HTTP/1.1
Host: www.directory.com
Connection: close
Accept: */*
User-Agent: WebBug/5.0Received Data
HTTP/1.1 200 OK
Date: Sun, 25 May 2008 17:11:43 GMT
Server: Apache
X-Powered-By: PHP/4.4.6
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
Now I entered the url with the subdirectory i.e http://www.directory.com/photogallery, the response is
sent data
GET /photogallery HTTP/1.1
Host: www.directory.com
Connection: close
Accept: */*
User-Agent: WebBug/5.0Received Data
HTTP/1.1 301 Moved Permanently
Date: Sun, 25 May 2008 17:16:47 GMT
Server: Apache
Location: http://directory.com/photogallery/
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=iso-8859-1
f2
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML><HEAD>
<TITLE>301 Moved Permanently</TITLE>
</HEAD><BODY>
<H1>Moved Permanently</H1>
The document has moved <A HREF="http://directory.com/photogallery/">here</A>.<P>
</BODY></HTML>
0
http://www.directory.com/photogallery
this part is getting the redirect problem but can't figure out where should i make the changes to fix it.