1

so I've got a problem. I want to make this URL https://example.com/l/click.php?id=something to look like this https://example.com/l/something

Does anyone know how to make it happen per code?

I tried editing & using this sample .htaccess code but it didnt worked :/

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?users/(.*?)/?$ /users.php?name=$1 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /users\.php\?name=([^\&\ ]+)
RewriteRule ^/?users\.php$ /users/%1? [L,R=301]

2 Answers2

0

You will need to implement rewriteRule in your .htaccess file in the directory where your php files resides.

Something like create a file called .htaccess and save the code below in it

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^([a-zA-Z0-9_-]+)$ click.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ click.php?id=$1

On your php you will have something like

<a href = "click/$id'></a>

or

<a href = "/$id'></a>

Always remember to shut down apache and restart it for it to take effect

Nancy Moore
  • 2,322
  • 2
  • 21
  • 38
0

So, I tested some .htaccess code and made my solution. It's pretty simple and works the best way it could!

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ click.php?id=$1 [L]

If you want to use it on your own just change the click.php to your own PHP file