How to make every request be directed to a subfolder? (HTACCESS)

3

I have tried several tutorials and none worked beyond index.php .

I use LOCALHOST and I want every request, of any kind, example:

localhost:8080/teste.php
localhost:8080/imagens/algo.jpg
localhost:8080/teste2.php?querystring=ok

Be redirected to the folder inside WWW like this: /wamp/www/PASTA/(os arquivos das URLs estão aqui) .

But I need the redirect if it could be invisible, it would be perfect.

What I tried and only redirected to INDEX.PHP of PASTA , but the other files got 404 error.:

RewriteEngine on
RewriteCond %{HTTP_HOST} localhost [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /pasta/$1 [L]
    
asked by anonymous 26.06.2015 / 21:09

1 answer

2

Here is what I used to redirect to a subdirectory. This happens invisibly and still allows requests to match an existing file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteRule ^(/)?$ subdir/index.php [L]
    
26.06.2015 / 21:10