.htaccess remove PHP extension conflicts with redirect url with variables

30 Views Asked by At

I have written code for changing the url from https://example.com/speciality_details.php?id=23&name=anaesthesia to this https://example.com/specialities/23/anaesthesia

Now I want to remove .php extension from every page but while I am adding code for removing extension the previous page that I redirected is showing not found.if I am adding a slash (/) at the end of the page name like https:example.com/about/ - then the CSS of that page is broken

Currently tried this code

ErrorDocument 404 /error.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule /$ - \[L,R=404\]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(\[^.\]+)$ $1.php \[L\]
RewriteRule ^doctor/([0-9]+)/([^\.]+)$ doctor_details.php?id=$1&name=$2 [NC,L] 
RewriteRule ^specialities/([0-9]+)/([^\.]+)$ speciality_details.php?id=$1&name=$2 [NC,L] 

I need both codes without conflicting with each other

0

There are 0 best solutions below