Re: [users@httpd] Limiting redirects with rewriterule/rewritecond
On Sun, Feb 25, 2024 at 5:29 PM Dave Wreski wrote: > Hi, > > In my ongoing effort to reduce the number of redirects for > linuxsecurity.com, I could use a bit more help. Currently we have one > redirect to strip off any potential trailing slash as well as another that > strips out any preceding 'www'. > > RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] > RewriteRule ^(.*)$ https://%1/$1 [R=301,L] > > RewriteCond %{REQUEST_FILENAME} !-d > RewriteRule ^(.*)/$ $1 [R=301,L] > > The rest of our redirects are of the form: > > RewriteRule ^/about/us /about [L,R=301] > > Should I be combining each of these to also do the above with something > like: > > RewriteRule ^/about/us/? https://linuxsecurity.com/about [L,R=301] > > It seems like that would reduce the number of redirects by two, but I'm > unsure of what implications that would otherwise have. Maybe if I instead > performed the RewriteConds without R=301 and just rewrote the URL itself? > I'm not sure how that works. > > Any ideas greatly appreciated. > Thanks, > Dave > > > Perhaps you can, but be careful about not creating loops, especially if using .htaccess files. Also, is there a specific reason why you're not using Redirect with mod_alias instead?
Re: [users@httpd] working with a reverse proxy
On Tue, Feb 27, 2024 at 5:10 PM Marc wrote: > > > > > > What would a best practice of 'informing' the proxyhost about that it > is > > being proxied and it should send the defaulthost hostname? > > > > can try > > https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost > > Proxy only works when I am having ProxyPreserveHost Off, I can't change > that. > > > - > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org What happens when you use ProxyPreserveHost, exactly?
RE: [users@httpd] working with a reverse proxy
> > > What would a best practice of 'informing' the proxyhost about that it is > being proxied and it should send the defaulthost hostname? > > can try > https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost Proxy only works when I am having ProxyPreserveHost Off, I can't change that. - To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
Re: [users@httpd] working with a reverse proxy
> What would a best practice of 'informing' the proxyhost about that it is > being proxied and it should send the defaulthost hostname? can try https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypreservehost - To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org For additional commands, e-mail: users-h...@httpd.apache.org
[users@httpd] working with a reverse proxy
I am having a more or less default setup where I proxy a website with something like this ProxyPass"https://${proxyhost}/en_gb"; ProxyPassReverse "https://${proxyhost}/en_gb"; ProxyPassReverseCookieDomain "${proxyhost}" "${defaulthost}" ProxyHTMLURLMap ... ProxyHTMLURLMap .. Everything on the default host seems to work quite well and you can navigate all pages that are proxied. The issue that I have is that the proxied website at some point does an api request to an external host, sending it's hostname. I want it to send the hostname of the defaulthost, not the proxyhost. What would a best practice of 'informing' the proxyhost about that it is being proxied and it should send the defaulthost hostname? Should I for instance set headers, and in the proxied website should I check on such headers? (Btw this is php). Or are there other things available like HTTP_X_FORWARDED_FOR