Page 1 of 1

Apache2 redirect only specific folders ?

Posted: 25 Aug 2022 13:15
by exxos
Does anyone know how to set up inclusions or exclusions in a permanent redirect ?

Currently I am redirecting ALL exxoshost URLs to exxosforum. However this is causing a problem with the site certificates because the exxoshost URL redirects to a exxosforum URL where the URL now incorrect :roll:

EG:

Code: Select all

getssl: for some reason could not reach http://exxosforum.co.uk/.well-known/acme-challenge/pmYWsIba5dGZ
The actual URL is valid bought Apaches redirecting it to exxoforum which is a different folder on the server.

Code: Select all

<IfModule mod_ssl.c>
	<VirtualHost *:443>
ServerName exxoshost.co.uk
ServerAlias www.exxoshost.co.uk
		DocumentRoot /var/www/html/
		SSLEngine on
Redirect permanent / https://exxosforum.co.uk/
	</VirtualHost>
</IfModule>

So is there any way to exclude the ".well-known/" Path from the redirect ?

Or alternatively only redirect folders such as exxosforum.co.uk/atari/ and exxosforum.co.uk/forum/ ? Could possibly be better I guess :shrug:

Re: Apache2 redirect only specific folders ?

Posted: 25 Aug 2022 22:02
by xyzzy76
Is this any good?

Code: Select all

RedirectMatch 301 ^\/((?!\.well\-known\/).*)$ [THEIR_REDIRECT_TO_URL]
https://servebolt.com/help/article/how- ... direction/

Re: Apache2 redirect only specific folders ?

Posted: 26 Aug 2022 00:47
by exxos
Oh cool. Thanks, never thought to look for my specific problem. I tend to just assume it's just me in the entire world who has such problems :lol: :roll:

Re: Apache2 redirect only specific folders ?

Posted: 26 Aug 2022 11:38
by exxos
That does seem to solve the problem but somehow created a new problem :(

EG www.exxosforum.co.uk/atari/last/ now redirects to the forum :shrug:

Re: Apache2 redirect only specific folders ?

Posted: 26 Aug 2022 13:57
by exxos
hmm odd.

REDIRECT OK

http://exxosforum.co.uk/atari/last/
https://exxosforum.co.uk/atari/last/

NOT OK

http://www.exxosforum.co.uk/atari/last/
https://www.exxosforum.co.uk/atari/last/

So for some reason www is not redirecting to where it is supposed to be going :shrug:

Also, why do these regex testers never do anything ?!

Capture.JPG
Capture.JPG (98.92 KiB) Viewed 1109 times

Re: Apache2 redirect only specific folders ?

Posted: 26 Aug 2022 14:44
by exxos
Bizarrely the redirect seems to work fine in Opera & FF but not in Chrome :pullhair: .

EDIT:

OK cleared the cache in chrome and now works.. Really getting fedup with chrome lately :roll: