How to create a rewrite rule to read a repository from a website subdirectory

Asked

Viewed 86 times

1

I have two folders in my root:

www/Repo-sp/
www/Repo-Rj/

My virtual host (www.meusite.local) points to www/repo-sp/:

When typing /rio at the end of the site, it should point to www/repo-rj/, that is to say, www.meusite.local/rio/

The problem is that I can’t play any files .htaccess at the root of these folders www/repo-rj/ and www/repo-sp/, but I can play at www or in a subdirectory of the sp repository /www/repo-sp/rio/.

Another problem is that I also need to maintain the idea that the /rio/ should be maintained when clicking on the menu link, for example "www.meusite.local/rio/link.html" when inside the river directory.

What I’ve tried and it hasn’t worked is, put the rule in a file .htaccess inside the river folder:

RewriteEngine on
RewriteRule ^(.*)$ /www/repo-rj/$1
  • Managed to make it work?

  • I did, but in another way. I didn’t actually have to create one. htaccess to the other repository, I made a symbolic link inside the SP project. inside the folder already had a . htaccess: RewriteRule . - [E=REWRITEBASE:/rio/]

1 answer

1

You could do more or less like this on . htaccess at the root of www :

RewriteRule ^rio/(.+) /repo-rio/$1 [NC]

In this rule he will take whatever is after the bar and direct completely to the '/river'.

I didn’t get to test it, but it might be a way or a start


Update:

I arrived at something interesting here, the . htaccess remains at the root of www:

<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteCond %{THE_REQUEST} ^GET\ /repo-rj/
    RewriteRule ^repo-rj/(.*)$ rio/$1 [R,L]

    RewriteRule ^rio/(.*)$ repo-rj/$1

</IfModule>

Whenever you access the '/rio/algo.html' it will fetch the 'something.html' inside the 'Repo-Rj'

  • Didn’t work no...

  • How he behaved himself?

  • he’s redirecting the subdirectory to another place.

  • I’ll make an environment here

  • I updated my answer!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.