Subdomains with Apache 2.2 - dns

I'm trying to set up a Apache 2.2 to work with subdomains. I've got a domain example.de which correctly points to the IP, my site www.example.com works. Now I want a bugtracker under bugzilla.example.com. All I did was to add a vHost with Servername bugzilla.example.com, but that does not work - the error message is "Firefox can't find the server at bugzilla.example.com.". Why is that? example.com should point to the correct IP?

If you did only add the vhost the most probable problem is that you didnt add the Subdomain to your DNS - Zonefile.

Related

VirtualHost not redirecting

I am trying to redirect http://eamondev.com:3000 to https://omniatm.eamondev.com with a VirtualHost. I am using node to serve a site to http://eamondev.com:3000. I am using vhost with node like this:
app.use(vhost('omniatm.eamondev.com', express.static('/')));
I have never used vhost and it took me a while to figure this out without having to split up all my code like I was working with more than one site (when I am not), so I'm not sure if it is exactly how it should be for an Apache redirect to work.
In my apache conf file I have:
<VirtualHost *:80>
ServerName omniatm.eamondev.com
ProxyPreserveHost on
ProxyPass / http://localhost:3000/
</VirtualHost>
I am also using WHM on a VPS, I'm not sure if this is relevant or not, but the ServerName (with protocol, what I type into the browser) needs to be https://omniatm.eamondev.com.
I cannot serve node on port 80 of my server (and then redirect to subdomain) because my main site (http://eamondev.com) is running on port 80.
I have referenced most of the stackoverflow questions about this and nothing has worked. I should mention (although I'm not sure exactly how it is relevant, I just saw it in a stackoverflow question I looked at), my hosting support (bluehost) used WHM to set things up with a wildcard ssl certificate to make the omniatm.eamondev.com subdomain https.
How do I redirect http://eamondev.com:3000 to https://omniatm.eamondev.com using apache (or vhost)?
Proxy passing as given in the question will not do any redirects instead it will retain the URL as such and proxy the content from elsewhere. In Apache configuration, we have an option to do redirects, in the bellow sample, we are checking for the host and based on it issuing an redirect to the desired URL
<VirtualHost *:80>
ServerName omniatm.eamondev.com
Redirect / https://omniatm.eamondev.com
<If "%{HTTP_HOST} != 'eamondev.com:3000'">
Redirect "^/?(.*)" "https://omniatm.eamondev.com/$1"
</If>
</VirtualHost>

Different ways to do a redirect

I'm working on an old website and I've just found something strange. Www.mysite.com redirects to www.test.com, while mysite.com (non-www) redirects to www.other-site.com.
I've checked the htacces, and it only contains rules to redirect traffic to test.com. www.other-site.com is not present in the file. So how is it possible? Where should I check if there's a rule for this redirect?
Environment:
Centos server /
Apache /
Three sites are on different servers
This could be a DNS issue. If both www.test.com and test.com point to the same server then it is all server side. Virtual hosts can sometimes be the problem if you have Apache set that way then you will need a Virtual host for both www.test.com and test.com. I would say start with the DNS, then the apache config, then the site folder.
Hope that helps.

AppHarbor points my domain to www.hostname.com but not hostname.com

I'm interested in having my website show up for both of these urls - www.example.com and example.com. DNS works properly and redirects www.example.com to 184.72.232.XXX and shows the website but not example.com. I've tried 2 hostname setups:
www.example.com, canonical=true
*.example.com (unable to set canonical)
Both hostname configurations have the same result.
You'll need to add "example.com" too (and keep "*.example.com"). The wildcard only matches subdomains. If you want the www version to be the canonical hostname, you'll need to add that as well.

How to do an Apache2 rewrite for ip based address

I have a development server that has Ubuntu server 10.10 with an ip of 192.168.0.175.
When I enable the rewrite mod for apache2 and change the site config to allow rewrite then things get all messed up.
With rewrite turned off and allow rewrites to None then I type in 192.168.0.175/test and the site loads, but with it all turned on it changes the address to www.192.168.0.175/test and the site does not load.
Why is this happening?
www.192.168.0.175 is wrong. If you type www the browser assumes that is a domain name.
The Ip's should be prefixed with www

redirecting without changing URL

i want to redirect domain domain1.com to domain2.com completely but without changing domain1.com URL.
i thought i could do that with .htaccess but i found out that it is not possible because they are to different domains and i should use http:// in .htaccess rule so it would be an external rewriting not an internal rewriting,so the URL will change.
is there any other solution? is using iframe the only solution?
i have to add that i don't want to change DNS setting for these 2 domains.
If both domains point at the same server then you can setup your apache config to point both domains at the same document root.
NameVirtualHost *
<VirtualHost *>
ServerName domain1.com
DocumentRoot /www/mysite
</VirtualHost>
<VirtualHost *>
ServerName domain2.com
DocumentRoot /www/mysite
</VirtualHost>
However, I would recommend domain2.com redirects (with a 302 redirect in the .htaccess) because it will improve your search engine optimisation, as both sites will be considered as one. So if a GoogleBot finds domain2.com as a link in another site, it will add it as a pagerank to domain1.com.
If they run on the same webserver you could set domain2 as an ServerAlias for domain1.
I thought I once read you could give a flag to mod rewrite that it internally proxies the request to another domain, however I have never used this myself (if it even exists) and I can't honestly say I think it'll be great for performance.. (but maybe it is..)
But why would you want two different domains show the exact same website, without changing the hostname to, what you see as, the primary one. If I might ask?

Resources