user5780640
user5780640

Reputation:

.htaccess 403 Forbidden

This is my HTML file:

<html lang="en">

<body>
    <h1>This is the HTML file.</h1>
</body>

</html>

PHP file:

<?php
echo "<h1>This is the PHP file.</h1>";
?>

.htaccess file:

RewriteEngine On
RewriteRule ^/?test.html$ test.php [L]

When I loaded test.html got the error:

Forbidden

You don't have permission to access /modul-1-froland/rewrite_test/test.html on this server.

instead of loading my test.php file. Any idea how can I fix it? Working in MAMP (http://localhost/modul-1-froland/rewrite_test/test.html)

Upvotes: 2

Views: 12413

Answers (1)

apokryfos
apokryfos

Reputation: 40700

Your rule says that your URL must start with test.html with an optional / at the start, however you're accessing /modul-1-froland/rewrite_test/test.html which does not start with test.html

Change it to

RewriteEngine On
RewriteRule test.html$ test.php [L]

to match all URLs which end with test.html

Upvotes: 1

Related Questions