A
A
Asjacker2020-09-30 16:06:30
htaccess
Asjacker, 2020-09-30 16:06:30

.htaccess how to hide .php?

Help me please! There is a site where users can register. A link must be created for each user. For example: example.com/username123.gif . The username123.gif file is the test.php file. I need to do something in htaccess so that when I follow the link example.com/username123.gif, the test.php file works. The name of the file in the link may be different, depending on the user's login. It is also necessary that this file can accept GET. For example:
example.com/username123.gif?qwerty
I'm very bad at all of this. Help me please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandr Pit, 2020-09-30
@AlexPitTech

Roughly speaking, everything is simple:
RewriteEngine on
# if a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to test.php
RewriteRule . test.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question