A
A
Arthur2016-02-26 16:14:06
Nginx
Arthur, 2016-02-26 16:14:06

How to set up a redirect from a directory to a symlink?

Hello.
Help set up the correct redirect

RewriteEngine On
Options +FollowSymLinks

RewriteCond %{REQUEST_URI} ^/page1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/page2/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/page3/(.*)$ [OR]
RewriteRule ^(.*)$ webroot/$1 [R=301,L]

here webroot is a symlink to the directory with pages page1, page2, page3, ...
so that when you go to example.com/page1 , the page located essentially behind the example.com/webroot/page1
symlink sees a variant of the view, but for some reason it is also does not work. rewrite is installed on the server with nginx->apache bundle
RewriteRule ^page1(.*)$ webroot/page1$1 [L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-02-26
@shambler81

But because you didn’t write the OP correctly, it ’s a
smart-ass topic and so awkward that I don’t even use it.
Here is an example of how it works.

RewriteCond %{HTTP_HOST} ^(.*)9918474\.ru$    [NC,OR]
RewriteCond %{HTTP_HOST} ^(.*)site4top\.ru$      [NC,OR]
RewriteCond %{HTTP_HOST} ^(.*)sunnyfruits\.ru$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(.*)u-kit\.ru$           [NC,OR]
RewriteCond %{HTTP_HOST} ^(.*)mediagrup\.ru$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(.*)vmast\.ru$         [NC,OR]
RewriteCond %{HTTP_HOST} ^(.*)desid\.ru$          [NC]
RewriteRule ^(.*)$ http://klondike-studio.ru/  [R=301,L]

Look at the penultimate line.
Try something like
RewriteEngine On
Options +FollowSymLinks

RewriteCond %{REQUEST_URI} ^/(page[0-9]{1,}/)(.*)$ 
RewriteRule ^(.*)$ %1/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question