0

I am having some issues with .htaccess. The issue is that my RewriteRule seems to be invalid even though I have used the same exact one several times before. The .htaccess rules are:

RewriteEngine On RewriteRule api/(.*) api.php?method=$1 

The issue is that when I visit my website, I get met with a 500 Internal Server error instantly. I tried editing the file to this:

Deny from all #RewriteEngine On #RewriteRule api/(.*) api.php?method=$1 

and I got permission denied (Expected behavior), so everything should work? I have no idea what is wrong with my htaccess file. I have tried doing the following:
- Restart apache using service apache2 restart
- What I said above, try a simple rule that will work if everything is correct and comment out the rest
- Writing the same rule in another file and replacing the text in my .htaccess file with that (I read somewhere that there could be "invisible" characters that .htaccess did not like at all)

0

1 Answer 1

1

You need to exclude the destination path your rule rewrites to otherwise you will get an infinite internal rewrite loop since your Rewrite pattern api/(.*) also matches the path /api/api.php .

RewriteCond %{REQUEST_URI} !/api\.php [NC] RewriteRule api/(.*) api.php?method=$1 
Sign up to request clarification or add additional context in comments.

1 Comment

The error shows as following: link I realize now what the error is, but I had never read the error log before as someone told me .htaccess errors don't get stored anywhere. Thank you very much though!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.