The code below works perfectly to direct all site traffic transparently into the www
folder:
Options -Indexes +SymLinksIfOwnerMatch
RewriteEngine on
RewriteBase /
# Verificar o destino
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
# Ignorar se estamos a apontar para a pasta do projeto
RewriteCond %{REQUEST_URI} !^/www/
# Ignorar se estamos a apontar para um ficheiro ou diretoria existente
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Direcionar tudo para a sub-pasta "www"
RewriteRule ^(.*)$ /www/$1 [L] [R=301,L]
The problem is in direct access via ww.example.com
that despite serving the page in conditions, results in an HTTP Status code 403 forbidden
which causes the failure of some services, among which social sharing.
However, if we access via ww.example.com/index.php
the HTTP status code is correctly identified as 200 OK
.
Question
How to resolve the access problem to www.example.com
so that they continue to drive traffic, but result in an HTTP status code 200 OK
?
Note: Web site navigation is performed with simplified URLs type:
www.example.com/produtos/bananas/banana-da-madeira