Search code examples
php.htaccesshttp-redirectlamp

Real subdomains with Godaddy


My .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^deathga.me$ [NC]
RewriteRule ^(.*)$ http://deathga.me/$1 [L,R=301]
</IfModule>

It correctly redirects from www.deathga.me to deathga.me, which solves many things. But it also redirects play.deathga.me to deathga.me/play/ , which is undesirable.

My question is basically the opposite to this: Redirecting http://example.com to http:/www.example.com while keeping http://subdomain.example.com access intact. Only I cannot figure out how to apply it to my site, even looking at that question, googling and trying many things. The question itself is pretty simple: how to redirect www.example.com to example.com but keep sub.example.com in that subdirectory? I am not even sure if it's a problem with Godaddy or with htaccess... where should I start looking into? This is a screenshot of Godaddy subdomain configuration:

view of the subdomain

EDIT: Full .htaccess now:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} !^play.deathga.me$ [NC] 
RewriteCond %{HTTP_HOST} !^deathga.me$ [NC]
RewriteRule ^(.*)$ http://deathga.me/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

</IfModule>

Solution

  • Apparently what I wanted to do cannot be done with the 'fake' godaddy subdomain and an Economy account: Setting up a "real" subdomain with Go Daddy .

    Thank you @borazslo for all the help.