Catch URL string and point it to different path, enable PHP
May 30, 2012 01:03PM
Sorry for the potentially poorly worded subject. What I'm trying to do is send requests for userdirs (~/something) to a "catch all" location on the filesystem that uses PHP.

So, the site's root is, for example, /var/www/site.com/ and I'd like to point requests for /~(.*) to /var/www/error/, which contains PHP.

I've kind of had it working using a few things, but nothing perfect, and certainly not clean.

So /var/www/error/ will have PHP files, css, etc.

When I have gotten it to work, I can't seem to get the paths in the various PHP or HTML documents to be correct. E.g. rather than a relative "/css/file.css", it tries to look for "/var/www/error/~user/css/file.css".

For a location match, I'm currently using: location ~ ^/~(.*)$ { }. Maybe that's not perfect, but really, I need anything from a userdir to go back to this error page (e.g. /~user/my_site/file.html), with PHP support.

I'd post what I have for config here, but I don't really have anything - I've just tried various combinations of using "root", "alias" and "rewrite" to accomplish this.

Any insight is greatly appreciated.
Re: Catch URL string and point it to different path, enable PHP
May 30, 2012 04:27PM
One detail,

location ~ ^/~(.*)?$ {
alias /var/www/error/;
index index.html;
}

This goes into a loop, obviously. Perhaps I need a mixture of rewrite and location(?)
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 101
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready