I want to redirect the sub-domain webmail to /roundcube for that domain. This have to work for all virtual hosts in apache.
Example:
webmail.example.com must point to [www.]example.com/roundcube
How is this possible? The server where it has to be done is configured with direct admin :S
mod_rewrite is your friend.
Try something like this in your Apache VirtualHost configuration:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail\.[^.]+\.[^.]+$
RewriteRule ^webmail\.([^.]+)\.([^.]+)$ http://www.$1.$2/roundcube [R=permanent]
...and configure DNS to point webmail.example.com to the same server as www.example.com.
Related
Apache virtual hosting url redirect from one domain to other domain without showing the url in the browser?
That's not redirect, that's called Reverse Proxy.
Example:
ProxyPass /url-path/ http://backend.example.com/url-path/
This will reverse proxy all requests to /url-path/whatever to the server backend specified
More information at:
http://httpd.apache.org/docs/2.4/mod/mod_proxy.html
http://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
No, there isn't a way to do this with .htaccess if your sites are on different servers. Doing so would present big security hole, imagine if someone does this with a bankĀ“s website.
However, if both are hosted on the same server try this on your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^http://www.domain1.com$
RewriteRule (.*)$ http://www.domain2.com$1 [P]
</IfModule>
If you own both domains you could accomplish this with domain name forwarding. Check the options in your registrar (maybe godaddy, or dns managers like cloudflare).
I have a requirement where I have to redirect my hostname to particular application which is again hosted on same Apache. Let's take an example, When I hit on host(https://domain1.example.com), It should internally redirect me to Apache Web Application (https://domain1.example.com/application1) without changing the browser URL.
I am not sure how to achieve SSL to SSL redirection. Thanks in Advance..!!!
This should work. This will redirect all incoming urls that are going to domain1.example.com/ to domain1.example.com/application1
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain1.example.com$
RewriteRule ^$ https://domain1.example.com/application1 [L,R=301]
If without changing browsing URL is your goal then PROXY is your way.
Put following in your apache vhost or global file,
ProxyPass https://domain1.example.com/ https://domain1.example.com/application1
ProxyPassReverse https://domain1.example.com/ https://domain1.example.com/application1
PS shibboleth has nothing to do with this, at least you have not mentioned any case.
EDIT
ProxyPass should come to virtural host not in location
Ideally all the location tag should be out of virtual host
We have different domains that are hosted on our server. Recently one of the main sections of our site has been moved to another server and been given a subdomain:
http://www.mysite.com/store
Has been moved to
http://store.mysite.com
Within our apache VirtualHost we wanted to redirect all traffic from the old domain to the new one:
Redirect permanent /store http://store.mysite.com
The problem is, we have other hosted sites that are being redirected now:
http://www.othersite.com/store
http://api.greatsite.com/store
We don't want this. How can I only have apache do redirects if http://www.mysite.com/store which has the /store path, and ignore other domains with /store?
Use mod_rewrite based code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$ [NC]
RewriteRule ^/?store(/.*|)$ http://store.mysite.com [L,R=301,NC]
A simple working 301 .htaccess redirect on my live server looks like this:
Options +FollowSymLinks
RewriteEngine on
redirect 301 /test.php /index.php
But I can't make it work my XAMPP installation.
I have enabled mod_rewrite.so in the http.conf file and I can't see why it does not redirect. Have restarted apache but no luck.
Just to let you know that Apache's redirect directive is from mod_alias module not from more_rewrite module. Check docs here: https://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect
If you want to handle it via mod_rewrite it then use it like this:
RewriteEngine on
RewriteRule ^test\.php$ /index.php [L,NC,R=301]
ALternatively enable mod_alias module to make redirect work.
Got it working by creating a local domain Using Apache Virtual Hosts. Once the local domain is setup, the redirect code works as it does on the live server:
redirect 301 /test.php /test2.php.php
I've got myself an apache server and I'm trying to learn it's quirks...
I've got DNS to point example.com to 1.2.3.4 and I've set up a vhost on the apache2 server.
Now I want to, in the same vhost, point db.example.com to serv the contents of example.com/db.
I was hoping I could use some kind of mod_rewrite og ServerAlias, but sofar I've hot a wall.
The DNS part is covered, I just can't figure out what to do in apache.
In your .htaccess file, try something among the lines:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^db\.example\.com
RewriteRule (.*) http://example.com/db/$1 [L]