O
O
olezhenka2017-08-25 23:27:20
Apache HTTP Server
olezhenka, 2017-08-25 23:27:20

Where to create .htaccess file?

I want that when loading a file, for example, auth.php, it is not necessary to add its extension in the address bar, and I created a .htaccess file in the /var/www directory and added the code there: RewriteRule ^(([^/]+/)*[^.]+)$ /$1.php [L]
but it does not work when trying to load the page site.ru/auth file auth.php does not open, although it works with the full address site.ru/auth.php
the question is, did I create .htaccess in the right place and did I find the right code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2017-08-26
@zkelo

You created the file in the correct directory, but you wrote the redirect regular expression incorrectly.
It is necessary, for example, like this: RewriteRule ^([a-zA-Z]+)$ /$1.php [L]
Regex101

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question