Home Apache RewriteRule for forbidding all URLs except one
Reply: 0

Apache RewriteRule for forbidding all URLs except one

user938 Published in June 19, 2018, 6:27 pm

I have a problem finding the right RewriteRules for my problem.

I want to configure a ruleset in a Apache vhost configuration.

My goal is that all URLs end at a 403 Forbidden. Only the /api call should go to the index.php, which is the entry-point for my symfony project.

Right now I have the following, but it does not work correctly:

        RewriteEngine On
        RewriteCond %{REQUEST_URI} !^/api$
        RewriteRule (.*) - [F]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php [QSA,L]

With this rules, all calls end as 403.

The other way round it works:

        RewriteCond %{REQUEST_URI} !^/api$

This way, all URls arrive in my symfony project. Except /api which ends at 403. But I dont want it this way. As mentioned I want it the other way round.

Thanks for your help!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311714 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO