Question:
I've tried several tutorials and none have worked other than index.php
.
I use LOCALHOST
and I intend that every request, of any type, for example:
localhost:8080/teste.php
localhost:8080/imagens/algo.jpg
localhost:8080/teste2.php?querystring=ok
Get redirected to the folder inside the 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 the INDEX.PHP
of the PASTA
, but the other files were giving error 404.:
RewriteEngine on
RewriteCond %{HTTP_HOST} localhost [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /pasta/$1 [L]
Answer:
Here is what I used to redirect to a subdirectory. This happens invisibly and still allows orders that 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]