Apache redirection to another port - apache

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/

Related

Apache reverse proxy - rewrite and Substitute returning answer

We have reverse proxy server which use rewrite rule to redirect one address to another.
When redirection is working, we get back an answer from that site (google) as a txt page.
Now, we wish to Substitute few words in that page and direct it to the source server that asked for it.
Our configuration looks like this:
ProxyRequests Off
RewriteEngine on
RewriteRule ^/books\.google\.com(.*) https://books.google.com/$1
Substitute "s/thumbnail_url/test/ni"
We do get the page back from google, but Substitute of words in the page is not working.
Hoping someone can answer it.
Thanks
Found the way to do so, by adding the following lines:
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
Substitute "s/thumbnail_url/test/ni" [P]
Cause [P] will made the all query to work with https (as rewrite rule defined) and two first lines support SSL on apache proxy.
Lavi

Apache redirection dependent on the given input

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

Redirecting all Unregistered Subdomains to Catch-All

We'd like to redirect all misspelled subdomains to a catch-all (primary domain), ex. dalls.domain.com needs to resolve to domain.com. Due to the very large number of subdomains we have, we can't simply create redirects for each possible spelling. Is there a way to wildcard redirect all non-registered subdomains to domain.com?
Thanks for any help or insight!
Not sure if this is exactly what you are looking for, but you can redirect all 404's quite easily with htaccess. The only downside is that all mispelled(or non-existent) directories and files will also redirect.
You can do this by adding this to your .htaccess:
ErrorDocument 404 http://domain.com
Hope this helps! I will edit this answer if I find a specific redirect for just wrong sub-domains.

How to change one url suffix to another in apache?

I hope I can explain this clearly enough, but if not let me know and I'll try to clarify.
I need to configure apache to redirect from one url to another e.g. mySite.com/maven2 should redirect to mySite.com/content/maven2. Do you have any idea how I should do this?
In php you can do this with:
header("LOCATION: mySite.com/content/maven2");
Or you can use a meta refresh...
Take a look at the Redirect Apache directive.
Redirect /maven2 http://example.com/content/maven2
You can use that in either .htaccess or httpd.conf

Apache: Redirect blog.foobar.com to www.foobar.com

I have a site at blog.foobar.com that I have closed down, and I want any
page requested there to be forwarded to www.foobar.com
I want my VirtualHost config to do this for me. I currently have the following lines that does nearly what I want but not exactly:
redirect permanent / http://www.foobar.com
Unfortunately what happens is that if I ask for blog.foobar.com instead of forwarding to www.foobar.com it serves the pages on blog.foobar.com instead.
Is there a way doing this in the VirtualHost config or should I use a .htaccess file instead?
Regards
Steve
You can use the Redirect directive in the context of either a VirtualHost or a .htaccess file. However, what you probably want is a RedirectMatch:
RedirectMatch permanent (.*)$ http://www.foobar.com$1
With that inside your blog.foobar.com VirtualHost, any request to blog.foobar.com would be directed to the same page on www.foobar.com, ie. blog.foobar.com/my/page would go to www.foobar.com/my/page.