Configure .htacces to access a file?

2

I have a symfony project in my root directory, and I have the following lines in my .htaccess

<IfModule mod_rewrite.c>
    RewriteCond %{HTTP_HOST} ^mipagina.mx$ [OR]
    RewriteCond %{HTTP_HOST} ^www.mipagina.mx$
    RewriteRule ^(.*)$ /web/$1
</IfModule>

With this my page goes well, but now that I want to have my file robots.txt in the root, as indicated by Google this can not be accessed.

If I put www.mipagina.mx/robots.txt I get a 404 not found message, since the symfony framework takes it as a controller.

How could I configure the .htaccess so that I do not take it as part of the project but as a file that is on the server?

    
asked by Isra 26.02.2018 в 19:27
source

1 answer

1

Putting a specific rule for robots.txt that causes no more rules to be evaluated:

RewriteEngine On
RewriteBase /

#Si accede a robots.txt, que no procese nada más
RewriteRule ^robots\.txt$ - [L]

# Y de paso uno tus dos condiciones en una ;-)
RewriteCond %{HTTP_HOST} ^(?:www\.)?mipagina\.mx$ [NC]
RewriteRule (.*) web/$1
  • The - tells you not to rewrite anything.
  • The [L] ( last ) tells you not to continue processing more rules.
answered by 12.03.2018 в 23:45