0

I've installed Piwik on the root of my Symfony2-based website (which should accessible at mywebsite.com/piwik/index.php) and I've tried to configure my .htaccess file so I can get around the 'No route found for "GET /piwik/index.php"' exception.

The problem is I am not good enough at configuring .htaccess, as a result I still get the above exception. Of course, I have to read tutorials. This is how I have tried to configure my .htaccess file:

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

Any suggestions ? Thanks in advance.

0

1 Answer 1

1

Symfony ships with this rewrite rule as a default in web/.htaccess:

# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]

So you should be able to drop the piwik/ directory within the web/ directory (thus, index.php will be [SymfonyAppRoot]/web/piwik/index.php) and access the page there.

By doing this, you allow Apache to serve /piwik/index.php before Symfony has a chance to get in the way.

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

4 Comments

Many thanks, @HPierce! It's working perfectly, you've made my day!
I have come to find out the app.php is no longer been reached, as a result I'm have the following exception whenever I request any resource: "The requested URL /mywebsite/web/diapers was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
@PatrickBass, That's odd. The rewrite rule I've highlighted here would not change that behavior. Without knowing anything more than you've posted here, I suspect you may have inadvertently changed one of the other defaults in .htaccess. I'd recommend you find a fresh copy of the default .htaccess that ships with Symfony and see what happens with that.
thanks again for your remark. Finally I manage to fix the issue by combining your approach and mine. I have reconfigured my .htaccess file as before (see my first code above) putting it in web/ folder and kept /piwik folder in /web as you advised.

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.