Mobile app version of vmapp.org
Login or Join
Jennifer507

: Overriding a redirect with an A record -- What am I doing wrong? We have a GoDaddy account and are using a redirect as a placeholder for our main site as dictated by management. They want

@Jennifer507

Posted in: #Dns #Godaddy #Redirects #Ubuntu

We have a GoDaddy account and are using a redirect as a placeholder for our main site as dictated by management. They want "dev" and "staging" to access our application but everything else to go to the redirect.

We want to have access to our application via a "staging" subdomain. I can't seem to get this thing to work. Between the GoDaddy Redirect, the DNS Zone file, the sites-enabled (on our server) and the hosts files, I am stuck. We're running on an AWS AMI running Ubuntu 14.04.3 LTS.

Here's what I'm trying to do (text and numbers have been changed to protect the innocent):

If you type in:
dev.phishmenot.com -> The site in our development directory on our server.
staging.phismenot.com -> The site in our staging directory on our server.
[anything else].phishmenot.com -> (REDIRECT 301: KickoffLabs website)

Our configuration is this:



Then, we have the actual zone file:



My hosts file (on our AWS server):

127.0.0.1 localhost
67.4.67.45 dev.phishmenot.com
67.4.67.45 staging.phishmenot.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


And here's my staging.phishmenot.com.conf file, sitting in the sites-available directory, with the symlink appropriately sitting in the sites-enabled directory:

<VirtualHost staging.phishmenot.com:80>
ServerAdmin admin@phishmenot.com
ServerName phishmenot.com
ServerAlias staging.phishmenot.com
DocumentRoot /var/www/staging/current
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


We're using KickoffLabs to do some of our site promotion and I followed their directions for setup. What is strange is that I DID get the dev site to work. I just can't remember how I did it. I think I just kept tweaking things until it worked and then had to get back to development.

I am most assuredly NOT a Unix or Server expert. Call me an informed amateur. I would like to get this configured in a standard way so when we get someone who DOES know what they're doing, it will be remotely recognizable.

UPDATE:

I tried the changes you suggested and I now can not reach my phishmenot.com site OR the kickofflabs.com site. Here's my .htaccess file; real names and addresses edited out, but consistent with this question:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^(dev|staging).phishmenot.com$
RewriteRule ^(.*) proxy.kickofflabs.com/ [QSA,L,R=301]
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|.svn) index.php/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [QSA,L]
Header set Expires "Thu, 19 Nov 1981 08:52:00 GM"
Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
Header set Pragma "no-cache"


Per the suggestion, I removed the redirect from GoDaddy, hopefully handling all through the .htaccess file. I also removed the CNAME record for "www" directing to the kickoff labs proxy. Now staging redirects to phishmenot.com which no longer addresses any server. I thought the @ in the a record was supposed to catch anything not listed as an A or CNAME record. NOTE: The additional mod_rewrite commands are supporting our application framework, CodeIgniter. If there is a conflict, I can make adjustments.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Jennifer507

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

OK Well looking at your setup, you want a htaccess redirect which is straight forward stuff.


Remove all DNS level redirects at GoDaddy.
If AWS is the main server that hosts the example.com then use the "@" a record entry as the IP of the AWS, this way non-www and www will work as intended.
On the staging and development server enabled mod_rewrite so that you can perform conditional rewrites.
Create a blank file and name it .htaccess i.e /var/www/dev/.htaccess in both staging and development.
Populate both .htaccess files with something like:

RewriteCond %{HTTP_HOST} !^(dev|staging|www).example.com$

RewriteRule ^(.*) www.example.com/ [QSA,L,R=301]


The above code will redirect all sub domains that are not dev, staging or www to the main site. I also recommend using a htaccess on the main site so you can gracefully redirect from non-www to www, hence why I mentioned about the A record using @ , the htaccess file should work on all 3 of your sites.

Managing your redirects server side works far better than they do at the DNS, never mind you can do more technical rewrites if needed, generally it is industry standard to redirect server-side should you engage into debate with your big boss men.

edit.

If you want to redirectly to a different domain entirely on anything else other than the sub domains mentioned then you should opt to use a .htaccess redirect on both staging and the dev site. Simply create a blank .htaccess in the root of both sites and fill the file with:

RewriteCond %{HTTP_HOST} !^(dev|staging).siteA.com$
RewriteRule ^(.*) www.siteB.com/ [QSA,L,R=301]


Again, ensure that your server is rewrite enabled, otherwise nothing will happen when testing.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme