Lucky Ali
Lucky Ali

Reputation: 335

how to change url in htaccess for two php files

I am dont know mutch about .htaccess. I need help here. I have this code in my .htaccess

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ pro_detail.php?client=$1 [PT]

which changes

http://xyx.pk/abc/pro_detail.php?client=umair

to

http://xyz.pk/abc/umair

now I need change

http://xyz.pk/abc/project_detail.php?project=dreamhousing

to

http://xyz.pk/abc/dreamhousing

please help. thanks

Upvotes: 0

Views: 198

Answers (1)

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57640

This url scheme will not work. Because .htaccess rules have no idea which text belongs to project or which text belongs to client. It'll always match the first rule. Its better you prefix project/ or client/. This way they can be mapped correctly. So use this,

RewriteRule ^client/(.*)$ pro_detail.php?client=$1 [L,PT]
RewriteRule ^project/(.*)$ project_detail.php?project=$1 [L,PT]

This will allow http://xyz.pk/abc/project/dreamhousing to map http://xyz.pk/abc/project_detail.php?project=dreamhousing

Upvotes: 1

Related Questions