haproxy - URL redirect with same path - haproxy

i need redirect http://example1.com/goofy in http://example2.com/goofy, I already use this line:
redirect location http://example2.com code 301 if { hdr(host) -i example1.com }
In this way if I go on http://example1.com/goofy I am redirect to http://example2.com and not http://example2.com/goofy, can anyone help me?
Thanks

Using pathq fetch from haproxy 2.2 will do this nicely:
redirect location http://example2.com%[pathq] code 301 if { hdr(host) -i example1.com }
https://cbonte.github.io/haproxy-dconv/2.2/configuration.html#7.3.6-pathq

Related

Deny access to URI in HAproxy

I want to deny access for few URI for eg:- /info/some. below is the config i am using but still getting 200 when doing curl.
acl bl_info path,url_dec -m beg -i /info/some
acl bl_para path,url_dec -m beg -i /param/some
http-request deny if bl_para
http-request deny if bl_info
Please suggest what is wrong here and what i should do ? Thanks in advance
I believe you are looking for something like this
acl restricted_paths path -m beg -i /info/some /param/some
http-request deny if restricted_paths

redirecting index.html to the root using httpd.conf

I tried to redirect all index.html to root folder by configuring Apache webserver httpd.conf using settings below. It's able to redirect successfully, however it keeps pointing to testsite.com// instead of testsite.com/. Any idea why it kept forwarding to the url with 2 slash '/'? Appreciate your advice, Thanks!
RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ $1 [R=301,L]
Remove that monstrosity and use:
DirectoryIndex index.html
also for missing resources:
FallBackResource /index.html

How do I redirect from "domain.com/folder/index.html" to "domain.com/folder"

My site runs on nginx
I have the code to redirect my root index.html to domain name but I don't know how to redirect index.html files in folders to point to the folder for 301 redirect
example root/folder/index.html to root/folder
this code worked in htaccess to redirect root index.html to domain name
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://%{HTTP_HOST}/ [R=301,L]

redirecting a subdomain to a domain using htaccess

I would like to redirect a subdomain to a folder in its main domain. The subdomain is blog.mydomain.com and I would like to redirect it to http://www.mydomain.com/blog.
I have tried to do this using an htaccess file as follows:
RewriteEngine on
Options +FollowSymlinks -MultiViews
RewriteCond %{SERVER_PORT} =80
RewriteCond 5{HTTP-HOST} ^blog.mydomain.com$ [NC]
RewriteRule ^(.*)$ /blog/$1 [PT,L]
but it doesn't work (the redirection does not happen).
Does anyone know how I could do this?
Thank you.
Try with
Redirect 301 / http://www.mydomain.com/blog
If that doesn't work,i'll try something else

htaccess & Zend Framework passthrough

I have the following htaccess file for my ZF project.
SetEnv APPLICATION_ENV production
# Redirect old site pages
redirect 301 /The_GAPS_Postal_Application_20110126.pdf /pdf/The_GAPS_Postal_Application_20110126.pdf
redirect 301 /The_GAPS_Constitution.pdf /pdf/The_GAPS_Constitution.pdf
redirect 301 /The_GAPS_EJ_Postal_Application_20110126.pdf /pdf/The_GAPS_EJ_Postal_Application_20110126.pdf
redirect 301 /The_GAPS_Fishery_Rules.pdf /pdf/The_GAPS_Fishery_Rules.pdf
redirect 301 "/Gipping Angling and Preservation Society Waters.pdf" /pdf/Gipping_Angling_Preservation_Society_Waters.pdf
redirect 301 /gaps_waters.php /waters
redirect 301 /alderson_lakes.php /waters/alderson-lakes
redirect 301 /barham_b_pit.php /waters/barham-b-pit
redirect 301 /causeway_lakes.php /waters/causeway-lakes
redirect 301 /perch_pit.php /waters/perch-pit
redirect 301 /river_gipping_barham.php /waters/river-gipping-barham
redirect 301 /river_gipping_bramford.php /waters/river-gipping-bramford
redirect 301 /river_gipping_elton_water_bank.php /waters/river-gipping-elton-water-bank
redirect 301 /river_gipping_lagoon.php /waters/river-gipping-shamford-lagoon
redirect 301 /river_gipping_shamford_lock.php /waters/river-gipping-shamford-lock
redirect 301 /river_gipping_sproughton.php /waters/river-gipping-sproughton
redirect 301 /gaps_maps.php /waters/maps
redirect 301 /gaps_rules.php /waters/rules
redirect 301 /joining_gaps.php /membership
redirect 301 /gaps_postal_applications.php /membership/postal-applications
redirect 301 /joining_gaps_early.php /membership/join-early
redirect 301 /joining_caps.php /membership/join-caps
redirect 301 /gaps_guest_permits.php /membership/guest-permits
redirect 301 /gaps_officers.php /officers
redirect 301 /gaps_match_fixtures.php /matches/fixtures
redirect 301 /downloads.php /downloads
redirect 301 /links.php /links
redirect 301 /gaps_work_parties.php /work-parties
redirect 301 /constitution.php /constitution
RewriteEngine On
# Cached files
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
RewriteRule ^/*$ cached/index.html [L]
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.html -f
RewriteRule .* cached/%{REQUEST_URI}\.html [L]
# Route to index.php for ZF
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
# Add compression
AddOutputFilterByType DEFLATE text/html
In my public_html folder I have a subfolder called lists containing a third party newsletter application. However calls to this folder just get redirected to the ZF application.
My question is how do I get the files in the lists folder to pass straight through rather than being directed to the ZF application?