3

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:

http://dev.phishmenot.com -> The site in our development directory on our server.

http://staging.phismenot.com -> The site in our staging directory on our server.

http://[anything else].phishmenot.com -> (REDIRECT 301: KickoffLabs website)

Our configuration is this:

Forwarding Pane from GoDaddy

Then, we have the actual zone file:

Modified Zone Management from GoDaddy

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 www.phishmenot.com site OR the www.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 ^(.*) http://proxy.kickofflabs.com/$1 [QSA,L,R=301]
# Hide the application and system directories by redirecting the request to index.php
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [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 www.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.

  • 2
    It's a little confusing what your trying to redirect from and to (i.e www.example.com to subdomain.example.com, but to start you off in the right direction, its generally better to use server-side hosting and leave the DNS alone. Since you will be using NGinx or Apache this is a fairly easy method via the conf file, or even easier by using a .htaccess rewrite. To make the question better received by the community please edit the question and include details of the site(s) your attempting to redirect from and where too (examples are key). – Simon Hayter Sep 25 '15 at 19:37
1

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

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

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

    RewriteRule ^(.*) http://www.example.com/$1 [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 ^(.*) http://www.siteB.com/$1 [QSA,L,R=301]

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

  • Thanks for taking the time, Simon. I want the system to reroute the user, when going to the MAIN site to a completely different URL. See above: "www.kickofflabs.com". Where do I put in the kickoff labs URL? – ScottK Sep 26 '15 at 15:45
  • Updated answer, by the way... seems silly. Its perfectly normal for sites not to return results when typing the url wrong... – Simon Hayter Sep 26 '15 at 16:13
  • siteB = kickofflabs, siteA = dev/staging – Simon Hayter Sep 26 '15 at 16:17
  • OK. Thanks. I will set this up shortly. We're doing things this way because our web app hasn't been released yet and we are using kickofflabs for our pre-release marketing--so we want anyone remotely interested in us to jump to the marketing. Once we're running, we'll go to a more traditional setup. – ScottK Sep 26 '15 at 16:49
  • Tried it with no success. See the update. – ScottK Sep 28 '15 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.