Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain Name Forwarding With Masking Breaking Viewport

So, I've discovered a rather interesting problem and was wondering if anyone else had come across it and maybe resolved it in some way.

I'm in the process of developing a responsive site. This site is hosted here. And the domain name iconclash.com is being forwarded with masking to the subdomain. Things were going well, however I noticed that on mobile devices my viewport meta tag wasn't working. After examining the page I noticed that this was being injected:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <title>ionclash.com</title>

</head>
<frameset rows="100%,*" border="0">
  <frame src="http://nicholasarehart.com/designs/" frameborder="0" />
  <frame frameborder="0" noresize />
</frameset>

This seems to be breaking the viewport tag. If you visit the subdomain directly, you'll see that the tag is working but if you visit the domain name that it being forwarded to it, it isn't. So, has anyone else ever seen this? Or resolved it? At the very least I think its something to be aware of.

Edit: seems someone else may have encountered this problem.

like image 373
Nicholas Arehart Avatar asked Jul 14 '12 12:07

Nicholas Arehart


1 Answers

EDIT: I just recently switched away from using GoDaddy's subdomain forwarding w/masking to instead use Apache's mod_rewrite tool on my own server to setup subdomains. This is much better in my opinion because there is no use of frames, etc. that causes the problem with viewport.

NOTE: you need to add a wildcard subdomain to point to your server's ip before the below method will work.

My directory structure is as follows:

/srv/http/
---------subdomains/
-------------------www/
-------------------sub1/
-------------------sub2/

My main website's code is located in the www directory, so it fits into how the subdomains work but isn't really a subdomain perse, since it's the main site.

Below is what I have in my httpd.conf file. It is the only VirtualHost.

<VirtualHost *:80>
  ServerAlias *.domain.com

  #Rewrite Starts*
  RewriteEngine on

  #This will just force www.domain.com if
  #only domain.com is given (to load our
  #code in the www directory) 
  RewriteCond %{HTTP_HOST} ^domain.com
  RewriteRule (.*) http://www.jmtk.co$1 [R=301,L]

  #RewriteCond %{HTTP_HOST} !^www.* [NC]
  RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com
  RewriteCond /srv/http/subdomains/%1 -d
  RewriteRule ^(.*) /subdomains/%1/$1 [L]
</VirtualHost>

Here is just some configuration info from my server for reference:

[root@server ~]# apachectl -v
Server version: Apache/2.2.24 (Unix)
Server built:   Mar 18 2013 13:57:39

[root@jmtksrv ~]# uname -a
Linux jmtksrv 3.8.11-1-ARCH #1 SMP PREEMPT Wed May 1 20:18:57 CEST 2013 x86_64 GNU/Linux

Hopefully this can be of use to you. It took me quite some time to finally get it just right after looking at several resources trying to explain creating subdomains with mod_rewrite.

like image 182
Taylor Avatar answered Oct 01 '22 19:10

Taylor