I have a vpn server which listens to https://sub.domain.com:943 and https://sub.domain.com:943/admin for the admin panel.
I would like to type on my browser (http) sub.domain.com or sub.domain.com/admin and the apache redirections, to redirect me accordingly.
I manage to do the first part my using a simple Redirect / https://sub.domain.com:943
But how can I achieve the second part?
Was so easy at the end, but I couldnt come up with that on that time.
Redirect /admin https://sub.domain.com:943/admin
Redirect / https://sub.domain.com:943
Related
I have a retail application that is hosted at www.emenu.com. My clients have there on websites that are hosted on their server, like www.fastfood.com, www.freshlime.com, etc. There is a button on their website which redirects to www.emenu.com.
www.fastfood.com on a button click redirect to www.emenu.com
www.freshlime.com on a button click redirect to www.emenu.com like that,
Problem is that the client does not want to show my application URL in the address bar after redirecting.
ie, www.fastfood.com will redirect to www.emenu.com but it should show www.fastfood.com in URL.
I am using laravel for the development. Came across many solutions involving .htaccess like
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?emenu\.come$ [NC]
RewriteRule ^ http://www.fastfood.com%{REQUEST_URI} [L,NE,P]
But the solution doesn't work.
The way websites work is like this:
user enters URL into browser (or clicks a link to get there), say www.example.com/foo/bar
the browser/OS looks up the A or AAAA DNS record for www.example.com, this DNS record points to an IP address
the browser sends an HTTP request to that IP address, like:
GET /foo/bar HTTP/1.1
Host: www.example.com
the server at that IP address (hopefully) responds with some HTML
So you see, if the domain www.example.com is already pointed at your client's server, it can't also point at your server. And the URL in the browser's address bar will always show the URL it's currently actually loading, you can't mask that. If you want the contents of your site to appear on your client's domain name, then the server pointed to by the DNS record for that domain actually needs to return the HTML for your site. You pretty much have two options there:
Embed your site in an iframe on your client's page. Say www.example.com/emenu.html contains:
<iframe src="http://www.emenu.com"></iframe>
Then visitors going to www.example.com/emenu.html will see the content of your site (embedded into a site of your client).
Set up the web server for www.example.com to reverse-proxy (some of) your URLs. In Apache that can be done with something like:
ProxyPass "/emenu" "http://www.emenu.com/"
ProxyPassReverse "/emenu" "http://www.emenu.com/"
Any HTTP request for the URL path /emenu to www.example.com would be forwarded by that server to your server, and the response be presented to the visitor as if the www.example.com server had produced it itself.
I'm in trouble with understanding the apache configuration to redirect an http to another.
I need to redirect the following:
http://test.com/foo to http://test.com:34567
and
http://test.com/bar to http://test.com:33490
I have seen that with that lines it redirects to another address, but I need to know if it will work before doing anything.
Redirect permanent "/foo" "http://test.com:34567"
Redirect permanent "/bar" "http://test.com:33490"
Thank you!
Yes, it works, If anyone wants, I tried it in https://htaccess.madewithlove.be/
I have multiple websites hosted on server using Webmin panel version 1.660
If I enter existing subdomain like www.domain2.com everything works fine, but for non-existing subdomains like wwwa.domain2.com server loads page from domain1.com
Is there any way to disable this feature?
I would like that non-existing subdomains would show 404 error or would be redirected to appropriate domain.
If you are using Apache, search Google for 404 redirects and url rewriting. Also if you want to take it future, then you also need to configure your DNS to catch all subdomains and redirect to your HTTP server
I have a new website as http://abc.com/case_studies/casstudy20/.
I have an old website as http://xyz.com/clients/home.php?client=myclient
There are loads of case studies and stories under old domain that is xyz.com. Now that I am using abc.com is it possible to replace the URL, so it shows abc.com but access the code from the same old place.
meaning when my users goes to old site instead of xyz.com. It should say http://abc.com/clients/home.php?client=myclient. But runs from the same old xyz.com.
Is it possible to do it using htaccess.
Sort of. You can redirect all the traffic from xyz.com to the proper path on abc.com but this requires you to maintain control of both domains.
If you can, it's actually better to put this in the virtual host config for xyz.com then you don't need a complete configuration at all. Assuming you have permissions it will work in .htaccess as well though.
RedirectMatch ^(.*)$ http://www.abc.com$1
If you can keep control of both domains then you are looking for a http 301 redirect. You can do that by adding the following line to your htaccess file to redirect an entire website. Without control of your original domain it's impossible for your old xyz.com website to be routed to the appropriate server so your htaccess file will never have anything to redirect.
redirect 301 / http://abc.com/
I'm trying to redirect all subdomain requests for domain.com to www.domain.com even when the subdomain does not exist, for example if we have:
abc.domain.com to www.domain.com
Where abc can be any requests. Furthermore, that subdomain abc may be exists or not. But whatever it is, I want to redirect it to main domain.
And less important request is. How it is possible to keep the input address at the address bar and redirect to main domain?
It will be best for me if it is done by .htaccess
I use apache server.
Thank you.
Since you haven't specified the environment you use, here are some general tips:
First, there is a difference between redirecting:
The user types sub.domain.com into the browser's address bar, but is redirected to domain.com -> domain.com is in the address bar, as the user is now on domain.com
...and rewriting an URL in the background:
The user types in sub.domain.com and stays at this address. The user sees sub.domain.com but in the background some other page (in your case, that one under domain.com) is loaded and shown.
(Quickly explained.)
If you are using Apache, take a look at 301 redirects and url rewriting.
In addition to what Piedone said (which is on the HTTP server side), you also need to configure the DNS to have a catch-all for all subdomains, directing them all to your HTTP server.
This implicitly means that all possible subdomains will exist automatically.