Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FB like URL Creation with .htaccess File and PHP

Tags:

html

php

Let website link is www.abc.com I have 3 PHP Files.

  1. index.php
  2. profile.php
  3. add.php

I want to convert

  1. index.php url like "www.abc.com/home"
  2. profile.php url (before - "www.abc.com/profile.php?id=no1") to "www.abc.com/user_name" (or "www.abc.com/abrar" or "www.abc.com/jahin" or "www.abc.com/piash" like this)
  3. add.php url like "www.abc.com/add"

I am using RAW PHP.

Can anyone help me please?

Thanks in advance.

like image 474
Abrar Jahin Avatar asked Dec 08 '25 21:12

Abrar Jahin


1 Answers

Update your .htaccess file by rewriteRule. Example:

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^home$ ./home.php
RewriteRule ^user_name/(\d+)*$ ./profile.php?id=$1

RewriteRule ^add$ ./add.php
like image 196
MH2K9 Avatar answered Dec 11 '25 11:12

MH2K9



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!