I have 2 pages Advertisement.php and Gidc.php and they work if they have user=”some value”
For example:
example.com/advertisement_final_page.php?user=sumeet
and
example.com/gidc_final_page.php?user=nikhil
I want code for htaccess to redirects it to above pages:
example.com/sumeet
and
example.com/nikhil
My database is:
id 1
Type Advertisement
user sumeet
contact 651651
owner Sumeet Patel
website asdfkjh.com
email sdfjh@skdj.com
address skjdf, sd, sdh
id 2
Type Gidc
user nikhil
contact 651651
owner Nikhil Patel
website sadfjh.com
email sdf@sdhf.com
address skjdf, sd, sdh
My htaccess rules:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ advertisement_final_page.php?user=$1
RewriteRule ^([a-zA-Z0-9_-]+)$ gidc_final_page.php?user=$1
But by above codes it reach to advertisement_final_page.php page.
Like if I enter
example.com/nikhil
it redirects to
example.com/advertisement_final_page.php?user=nikhil
The patterns in your rules seem to be identical. The RewriteEngine will match the first rule it can, in this case the first.
You should probably write a controller file that you redirect all your requests to. Then read the required user from
$_GET['user'], read the user’s data from your database and redirect/include the appropriate PHP file based on the user’sType.