D
D
davydov_v_b2018-07-02 11:11:31
htaccess
davydov_v_b, 2018-07-02 11:11:31

How to remove PHP to put a slash in a separate folder?

Hello!
Please help, I can't find a solution.
It is required for all files of the /forum/ directory with the php extension to remove php and put a slash.
That is, redirect all files https://www.site.ru/forum/forum12/topic2401.php to https://www.site.ru/forum/forum12/topic2401/ Found solutions for the entire site, but then all files are redirected , and I only need in this directory /forum/. There is no physical directory.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Viktor Taran, 2018-07-02
@shambler81

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/forum/.+\.php$ 
RewriteRule ^(.+)\.php /$1 [L]

J
Johnny Smith, 2018-07-02
@Olek1

mod_rewrite

E
Eugene M., 2018-07-02
@punkbot

Try this construction in .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/forum/(.*)$ /forum.php [L]

and in forum.php add a request handler.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question