0

I want to restrict the access to my directory (and redirect to my index.php) but it is not working well. When i change the extension from PHP to HTML it works fine, but I cannot make it work for php

This is what I have in my .htaccess:

Options All -Indexes

<files .htaccess>
order allow,deny
deny from all
</files>

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /index.php [L,QSA]

I'm new to all of this, so I really don't know how to solve this.

Thanks!

6
  • Make sure that mod_rewrite is enabled in your Apache server. You can check this by running apachectl -M, and look for rewrite_module (shared). If mod_rewrite is not enabled then you can enable it by adding LoadModule rewrite_module modules/mod_rewrite.so in your httpd.conf file.
    – clxrity
    Commented Jan 12, 2023 at 20:07
  • Also, check your PHP handler is set correctly in Apache. Make sure that PHP is being handled by the correct handler, such as mod_php or PHP-FPM.
    – clxrity
    Commented Jan 12, 2023 at 20:08
  • sorry if my question sounds dumb... but where can I check those things? Commented Jan 12, 2023 at 20:20
  • 1
    On Windows, the Apache configuration files, including httpd.conf, are typically located in the C:\Program Files (x86)\Apache Group\Apache2\conf or C:\Program Files\Apache Group\Apache2\conf directory.
    – clxrity
    Commented Jan 12, 2023 at 20:24
  • i found in httpd.conf this line: #LoadModule rewrite_module modules/mod_rewrite.so. I removed the # and retried, but it doesn't did anything Commented Jan 12, 2023 at 20:37

0

Your Answer

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

Browse other questions tagged or ask your own question.