10

I've got a duplicate content problem with my Symfony2 projet. The following urls gives the same content :

www.mywebsite.com/web/page and www.mywebsite.com/page

Here is the content of my /.htaccess file :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ web/$1 [QSA,L]
</IfModule>

And the content of my /web/.htaccess file :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

I would like to redirect any url starting with /web to / but I can't manage to do it. Do you have any suggestion ?

2
  • 2
    Can someone explain me why this question were closed as "off topic" in order to know it for the next time ? Commented Apr 17, 2013 at 22:14
  • As said here, questions related to htaccess are not necessarly off topic on SO. I then voted to reopen it as it has not even been moved to another site. Commented Dec 5, 2014 at 16:18

1 Answer 1

9

In the htaccess file in your web directory (the /web/.htaccess file), add these rules right beneath the RewriteEngine On:

RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /web/
RewriteRule ^(.*)$ /$1 [L,R=301]

This redirects all direct access to the web directory to the root.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.