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:
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 [email protected]
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.
www.example.com
tosubdomain.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).