S
S
Soft_touch_plastic2020-07-27 14:16:57
htaccess
Soft_touch_plastic, 2020-07-27 14:16:57

How to hide file extension in browser bar?

Hello, I googled on this issue, everywhere they force this code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

But it does not work for me, on an open server. The .htaccess file is correct, what's the matter?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kocherman, 2020-07-27
@kocherman

As far as I remember, although apache is present in openserver, it is, as it were, not used by default. Instead, nginx is launched. You need to either switch to Apache, or do the same, but with nginx configs and not Apache ones. .htaccess is purely Apache stray. There is no such thing in Orthodox nginx.

L
Lynatik001, 2020-07-27
@Lynatik001

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

example from google. - I think you're missing a slash

F
FanatPHP, 2020-07-27
@FanatPHP

This code is not "forced" anywhere because it is meaningless.
Like the "hide file extension" task itself.
If your task is to make "beautiful" (they are also "human-understandable") addresses, then you should write it this way and look for the code for this task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question