r/PHPhelp • • Nov 10 '25

Solved HTACCESS beginner error

Hello,

I have one htaccess :

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

`RewriteRule ^([a-zA-Z0-9-]*)\/([a-zA-Z0-9-]*)/?$ index.php?controller=$1&action=$2 [NC,L]`

But for exemple if i type this URL

https://mywebsite.com/logout
I have one 404 error.

But if i write :

https://mywebsite.com/logout/

It work.

Can you help me please

3 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/SatisfactionVast5052 Nov 11 '25

How can i make for add or not /

Please

1

u/greg8872 Nov 11 '25

The handling for the trailing slash you would have to do in your code in index.php that parses the request