First of all, sorry if I got the term 'pseudo subdomain' wrong.
what I am trying to achieve is this-
When someone registers on my application, they get a new url like..
yourname.myapp.tld
I dont want to use the subdomain system for this. To be frank, I dont know how the subdomains exactly work but it guess it requires a folder per subdomain inside the document root and then the server redirects the requests there.
Can this be achieved by doing something like -
when a visiter types any subdomain, (anything.myapp.tld), he is able to access myapp . In the index.php file i will explode the $_SERVER['HTTP_HOST'] to get the subdomain which i will store in session and will thereafter act as an identifier for that user. Ideally i wouldnt want to create any vhosts or add many lines to the hosts file. Can this be achieved with just one vhost?
Is this possible with mod rewrite or something ?
Yes you can archive this using wildcard that needs to be configured on both, the dns server and http server
On the dns a entry like this (installing dns on ubuntu https://help.ubuntu.com/10.04/serverguide/C/dns.html):
; wildcard subdomains are all directed to this IP
; of course this should be the IP of your web server
*.domain.tld. IN A 1.2.3.4
At apache an entry like this:
<VirtualHost 111.22.33.55>
DocumentRoot /www/subdomain
ServerName www.domain.tld
ServerAlias *.domain.tld
</VirtualHost>
What happens after is that everything.domain.tld will be going to your main folder so you can use the index.php to redirect it to the right place or even an htaccess using mod_rewrite.
Related
I have two servers running Apache2, one with an associated domain name, let's say "www.home.com" and another one only known by its IP address, let's say 10.11.12.13.
On www.home.com I have three web sites, configured through aliases in apache.
I have http://www.home.com, http://www.home.com/school, http://www.home.com/work.
All these sites are on the server www.home.com.
On 10.11.12.13, I have only one site, accessible by http://10.11.12.13/wiki
How can I configure apache to have http://www.home.com/wiki working but transparently (not changing URL) call http://10.11.12.13/wiki site ?
In other words, the user shall only see www.home.com/wiki/xxxxx when he uses the wiki.
What I have done:
On www.home.com : i have added a wiki folder with nothing in it, and an alias for www.home.com/wiki to work properly.
Then I have tried to use mod rewrite to replace 10.11.12.13 by www.home.com but that does not work, and I am not even sure to do it the right way.
For your information, mod rewrite is configured and works properly on both servers.
Someone could please help me on that ?
Maybe mod rewrite is not the right solution ?
Thanks !
Sam
I finally found a solution : the mod_proxy along with tags.
The conf that worked for me:
<VirtualHost *:80>
[...]
ServerName www.home.com
<Location /wiki>
Allow from all
ProxyPass "http://10.11.12.13/wiki"
ProxyPassReverse "http://10.11.12.13/wiki"
</Location>
</VirtualHost>
I have this site that needs to be inside our secure network that my work uses. I would like to redirect the users when they are trying to access the page to this secure path. For example, If someone tries to access mydomain.com/pictures I want apache to take them to https://mycompanysecure.com/,ThisSite=mydomain.com/pictures,SSL. I want the whole entire site to be redirected like the example above. I think I need to use wildcards, but I am really new on Apache and I don't know how to do this. I want also want also to make it the default when my app launches it always stay like that. So far I was only able to do this with the root path.
This is what I have so far:
<VirtualHost *:80>
ServerName mydomain.com
redirect / https://yourcompany.net/,ThisSite=mydomain.com,SSL
</VirtualHost *:80>
You can capture and substitute the URL by using RedirectMatch:
RedirectMatch ^/(.*) https://yourcompany.net/,ThisSite=mydomain.com/$1,SSL
I have found many suggestions around the net on this, but nothing that matches my exact issue. I have a webserver setup, that I have had our networking guys give me a DNS name for. Let's call it analytics.mycompany.com. This runs on port 80 and I have not issues.
A few months back I created an RStudio Shiny app that, by default, runs on port 3838. Therefore, I get to this via http://analytics.mycompany.com:3838/dashboard/. Which is all good and fine, but leadership has asked for an easier URL. I had my DNS guys give me an alias to the analytics.mycompany.com as dashboard.mycompany.com. Which, by default just points to the same port 80 website.
Now, I figure with a little apache/virtualhost/rewriterules/proxy I can tell apache to handle anything it receives from the dashboard.mycompany.com to just display the dashboard at http://analytics.mycompany.com:3838/dashboard/. After playing with this, I can get a URL like http://analytics.mycompany.com/dashboard/ to forward to the correct :3838 port and URL, but what I really want is for someone to be able to just enter http://dashboard.mycompany.com and just have the shiny dashboard appear. I know in DNS you cannot make aliases to ports, so that is out. I was hoping apache could handle this in some way, by saying, "ok, I have this URL on port 80 and I'm going to just display the content of this other site at port 3838."
I'm not sure if this is possible, but it is what I'd like. Right now my httpd.conf file for the virtual host at port 80 is as such:
<VirtualHost *:80>
ServerAdmin admin#mycompany.com
DocumentRoot /var/www/html
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^HEAD
RewriteRule ^/dashboard(.*) /foo/index.html
Redirect /dashboard http://analytics.mycompany.com:3838/dashboard
ProxyPass /dashboard/ http://analytics.mycompany.com:3838/dashboard
ProxyPassReverse /dashboard http://analytics.mycompany.com:3838/dashboard
</VirtualHost>
This was based on an example I found and is as close as I've come. I am thinking that I need some sort of virtual host for the new alias that might look like:
<VirtualHost dashboard.mycompany.com:80>
.....
</VirtualHost>
However, all the examples I find of VirtualHost is either *:80 or some IP addres like 192.168.0.1:80 or the like. If anyone has a suggestion or a way I can server this up at a simple URL, I would greatly appreciate it. Thank you so much!
To bring this to a close, this was a two part process:
I had to disable SELinux as it was interfering.
I created a VirtualHost entry as specified above (basically a port redirect)
Since we use a primary DNS, I had to have my network folks add an entry to InfoBlox for the domain.
After that, everything was working as expected. :)
I have an apache server with some websites built in Wordpress, using vhosts.
The thing is that I have for all of them a configuration like:
ServerName site1.com
ServerAlias www.site1.com
When I access to Site1 through "site1.com" the URL changes to "www.site1.com". The same for Site2, Site3, etc. But for SiteN it's inverse. If I access to "siten.com" it keeps the URL and if you go to "www.siten.com" it changes to "siten.com".
I know I can change this using htaccess file, but my doubt is why some sites has a default and the new site has another default? All the htaccess have the same things and the vhost configuration is the same for all.
Thank you,
Done! The change should be implemented in Wordpress configuration, is not a htaccess issue
I'm having issues to clearly manage my website redirection. Let say that I'd like to create a invisible redirect from www.siteA.com to www.siteB.com/content. Here you have what I'd like to have:
www.siteA.com --DNS--> www.siteB.com --Apache on siteB --> /wwww/content/siteA/
For the first part, I can do it using "CNAME" configuration at DNS level.
However, I'd like to have a kind of Apache rewrite rule on "www.siteB.com" machine in order to redirect to "/wwww/content/siteA/" only if we come from www.siteA.com DNS requests.
Any idea?
Did you look at apache virtual hosts http://httpd.apache.org/docs/2.2/vhosts/ ? It does exactly what you ask for as I understood it - at least the second part.