D
D
danyfir2020-08-28 14:23:00
htaccess
danyfir, 2020-08-28 14:23:00

How to allow slash and other characters at the end of URL in htaccess file?

Good afternoon! I can't get over the slash at the end of the URL. All pages are written in php
The site easily opens at domen.ru/page.php and domen.ru/page
But when you try to access the link domen.ru/page/ gives "Not Found The requested URL was not found on this server."
There were also problems with passing GET parameters. If you pass it through the form, then the variable is passed, but if you manually write the query domain.ru/page/?id=2 into the address bar, then again "Not Found The requested URL was not found on this server."

My htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danny Arty, 2020-08-28
@DanArst

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*/[^/\.]+)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L]

if the site is with https, then change accordingly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question