Targeting all traffic from root to sub folder results in error "403 forbidden" if it does not have "index.php"

6

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
    
asked by anonymous 18.03.2015 / 12:41

2 answers

1

When using flag (flag) R=301 rewrite forces the redirection, which I understand you do not want to redirect, but only rewrite the URL, if applicable, you do not > you should use flag , just use:

RewriteRule ^(.*)$ /www/$1 [L]

I suppose that the www folder is a create folder for you and not the apache use folder, for example, if it were a linux system your folder would be something like /var/etc/www/www , if so then your code would seems correct, except for the R flag.

In case I always use the QSA flag next to the L , in case I want to pass parameter GET together (for example if it comes from a Google ad /?gclid=... ), it would look something like:

RewriteRule ^(.*)$ /www/$1 [L,QSA]

Details: link

    
21.06.2015 / 04:12
0

I think I've tried, but you've put it this way:

# Direcionar tudo para a sub-pasta "www"
RewriteRule ^(.*)$ /www/index.php$1 [L] [R=301,L]
    
18.03.2015 / 14:05