R
R
rs4912020-12-27 18:30:38
Apache HTTP Server
rs491, 2020-12-27 18:30:38

How to redirect all requests starting with a prefix to a specific folder?

Hello everyone, and Happy New Year.

I ran into a problem, but my search didn't turn up any results.
A number of wordpress sites and one laravel project are deployed on the server in a separate directory.

The task is that on all these sites it is necessary that when accessing a URL with a certain prefix, a laravel project opens. ( site1.ru/prefix, site2.ru/prefix)

To begin with, I created a symbolic link to the laravel directory.
ln -s /var/www/laravelproject prefix

After that, when you go to siten.ru/prefix, the laravel project actually opens. But with a higher nesting level (siten.ru/prefix/user), this url opens WordPress, and accordingly does not find it, giving 404.

I need absolutely all requests starting with prefix to go to the laravel project.

I also tried to solve the problem through Alias ​​and AliasMatch in the apache config

AliasMatch /prefix/(.*)$ /var/www/laravelproject/$1 - No result at all
Alias ​​/prefix/ /var/www/laravelproject/ - The same result as and in the version with symbolic links

I would be grateful for any help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-12-28
@rs491

let's decompose and solve this

After that, when you go to siten.ru/prefix, the laravel project actually opens. But with a higher nesting level (siten.ru/prefix/user) this url opens WordPress, and accordingly does not find it, giving 404

obviously the problem is in the regexp alias match
https://stackoverflow.com/questions/9906433/aliasm...
obviously, you need to go to the left side, see what it maps to,
and then to the right side - is it able to process the request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question