Forum Moderators: phranque

Message Too Old, No Replies

Subdomain Creation Headache

Subdomain gets redirected to domain.com/subdomain

         

abhishekn

2:42 pm on Jun 1, 2007 (gmt 0)

10+ Year Member



I've got Wordpress installed on my root folder at example.com with a custom .htaccess file having the contents:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST}!^example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I think the problem is related to this .htaccess file as it disappears when I delete it. But I need to keep the file to use a custom permalink structure for wordpress.

The Problem: I create any subdomain, say xample.example.com(try it on your web browser). The address bar reads example.com/xample when I try to visit test.example.com. I want to retain xample.example.com in the web browser's address bar. I don't want to use domain masking(it isn't there in CPanel anyway).

Please can you tell me what to do?

[edited by: jatar_k at 3:40 pm (utc) on June 1, 2007]
[edit reason] please use example.com [/edit]

jdMorgan

11:45 pm on Jun 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Replace the first RewriteCond/Rule pair with this:

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

The rule you've got now clearly redirects requests for any hostname NOT example.com back to example.com, making all subdomains which resolve to this directory inaccessible.

Jim