1

I created a mobile version of my website by adding a subdomain m.mywebsite.com, but when I type in this in the browser, I am getting "server not found" error message. When I typed mywebsite.com/mobilesitefolder, all works ok. What changes to my .htaccess file should I do to make it work?

Thats my current .htaccess content:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
Radi
  • 83
  • 3
  • 13
  • DNS is cached. It can take some time for changes to propagate. Check the dns records for your site and make sure that the subdomain translates to your server. – Sumurai8 Jun 29 '14 at 14:04
  • Thanks for your reply, where can I check that subdomain translation? Is this the same thing as when setting up new domain for a website and you have to wait up to 48hrs to see the changes? I just used domain propagation checker and under A it showed nearly all servers working, but few still red crossed. Hopefully that solve my problem. – Radi Jun 29 '14 at 14:13
  • When that is propagated it should hopefully start working. – Sumurai8 Jun 29 '14 at 14:20
  • What about subdomain .htaccess file? What should be in it? – Radi Jun 29 '14 at 14:26

1 Answers1

0

If requesting your subdomain yields a "server not found" error, that means that the DNS record is not configured correctly, or that the DNS record has not propagated to all root level DNS servers yet. Check and double check that the DNS record translates to your server (e.g. with a CNAME) and then take a coffee (or other favourite beverage) and wait. When the DNS record propagates to all root level DNS servers it should at least connect to your server.

If your subdomain gets it's own www-root folder, e.g. /subdomains/m/ then just move your mobile site there. If your subdomain and normal domain point to the same folder, you'll need to do some .htaccess magic:

RewriteEngine on

#If host starts with m. and we are not in the m subdirectory...
#...we internally rewrite it
RewriteCond %{HTTP_HOST} ^m\.
RewriteCond %{REQUEST_URI} !^/m/
RewriteRule ^ /m%{REQUEST_URI} [L]

#If the host doesn't start with m. and we are in the subdirectory...
#...we redirect the sneaky person
RewriteCond %{HTTP_HOST} !^m\.
RewriteCond %{REQUEST_URI} ^/m/
RewriteRule ^m/(.*)$ http://m.example.com/$1 [R,L]
Sumurai8
  • 20,333
  • 11
  • 66
  • 100
  • Alright, dns is now propagated and the site is accessible. Now I would need .htaccess redirect code, so if anyone is accessing the site on a device with resolution lower than 768px will be transferred to m.mydomain.com, and the rest to mydomain.com. I found few here on Stack, but none seemed to work. Thanks. – Radi Jun 30 '14 at 00:14
  • You cannot get the viewport from .htaccess. If you want to do this via .htaccess, you need to take a giant list of mobile user agents and use that to redirect if no cookie is set. [This answer of me](http://stackoverflow.com/questions/23789858/mobile-redirect-to-desktop-version-using-htaccess/23813796#23813796) hopefully helps you. If you really want to do it based on viewport, you'll need a solution in javascript. There is probably already a question about that somewhere, but I can't quite find one right now. – Sumurai8 Jun 30 '14 at 09:56