last day (15 days later) » 

11:08 PM
1
A: Apache mod_alias RedirectMatch everything except specific pattern

CheeryAs it was said in comments - it is easier to do with mod_rewrite. Possible solutions RewriteEngine On RewriteCond %{REQUEST_URI} !^/bar/(abcd|baz|barista|yo)$ [NC] RewriteRule ^ http://site/ [R=301,L] Another one (for .htaccess, as initial / is removed from RewriteRule) RewriteEngine On Rewri...

 
I understand mod_rewrite would be easier but I explicitly said that I need to use mod_alias. As for the cache, I had that in mind and tried several different endings (abcd, baz, etc - new one every time) as well as monitored the HTTP requests to make sure the browser was actually getting the right redirection headers.
 
@borfast I checked the last example - it works.
 
just tried it, no joy.
 
@borfast I tried it and it works (Ubuntu, Apache 2.4.7, tried all of them). It means that your problem is not in this line, but somewhere else. Not enough information to tell exactly where it could be.
 
that's pretty much the conclusion I'm coming to as well. I just updated my question with the full virtual host config, in case someone can spot the problem there.
 
11:08 PM
@borfast Did you try to put RedirectMatch inside of Directory? or, at least, after the DocumentRoot (not sure that it matters, but worse of trying). I used .htaccess, but can try to test in config too.
 
Had not tried it before but just tried it now, both possibilities. Even tried it on another browser. No joy.
 
@borfast just tested in VirtualHost - works perfectly. Only added RedirectMatch 302 ^/(?!bt/sub/(went_active|success|cancel|expired)$).*$ https://localhost to it, nothing else. Something is wrong with your Apache.
 
The interesting bit is that our live server is having the exact same behaviour as my local dev environment, and this is a brand new server with the latest Ubuntu. This is driving me nuts... :|
 
@borfast try the rule in .htaccess. Also you might have some other rules interfering with this one. Or, for example, you finally get into the php or other script that redirects you.
 
I just tried something that doesn't even involve PHP (it wasn't installed) and got the same results. I did notice a pattern, though. Check the update at the bottom of my question.
 
11:08 PM
@borfast do you actually have those folders on the server? The problem might be inside of them - apache checks .htaccess in each of them coming up from the directory to the root of the server. If directories exist, another .htaccess in them may be used first. 403 Forbidden probably means that you get to the existing directory with indexing of the files in it turned off.
 
No, not in the original set up; they're just paths handled by a PHP/Laravel application. But on the test VM there was only one directory: /home/vagrant/www/bt/sub/went_active, and /home/vagrant/www/bt/sub/success didn't exist. It was also just a plain virtual host with no application installed. There was no .htaccess in that one directory, or anything else involved. In fact the VM didn't even have PHP, it was a plain Ubuntu Trusty installation with only Apache 2.4 installed on top of it (sudo apt-get install apache2). Couldn't get any purer than that for testing, I think.
 
@borfast Sorry, but I can not reproduce a problem - it works in my configuration. It is not completely 'pure' as I'm using it for some other purposes, but nothing extraordinary. I'll try a pure installation, but not today.
 
I understand, and I appreciate your time and effort. Hopefully someone will be able to make some sense out of this.
 
@borfast I just made a clean installation of Ubuntu Server (without LAMP or Apache, clean one). Installed Apache, added this RedirectMatch and guess - it works! oi61.tinypic.com/2hebi8h.jpg
 
thanks for the update. There is definitely something wrong going on here. I even tried a newly installed browser to make sure it was nothing on the one I've been using, and it still didn't work. Even worse, I get the same results in our production server. It's driving me crazy! But maybe it is something on the client side. I'll try a different computer altogether, see if that helps.
 
11:08 PM
@borfast if you can give me access I can take a look at it.
 
Thanks for the offer, Cheery, but it's a project from the company I work at and I'm afraid I don't have the authorization to allow non-employees to access the code. By the way, just as a curious note to add a bit more madness to the already interesting situation: I also tried the mod_rewrite options and I'm still getting the same result - I always get redirected even when the URL matches the regex. Nuts...
 

last day (15 days later) »