0

Here is my url and i wanted to remove engine-body.php?id=2 to engine-body/2

http://localhost/BMW/userSide/series/engine-body.php?id=2

also i wanted to remove folders name BMW/userSide

i am able to remove .php extention from file name but when i try to remove folder name my url do not work.

RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d

RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^BMW/(.*)$ /$1 [L,NC,R]

through this line i am able to remove .php and my urls work fine

RewriteRule ^([^\.]+)$ $1.php [NC,L]

but when i add this line to remove folder name

 RewriteRule ^BMW/(.*)$ /$1 [L,NC,R]

i am able to remove folder name but my url do not work .Here is my url after this

http://localhost/userSide/series/engine-body.php?id=2
Egg
  • 1,782
  • 1
  • 12
  • 28
phpDev
  • 39
  • 5
  • 2
    Why you tag mysqli into this question?? – Saty Apr 15 '16 at 12:50
  • A different way of doing it could be explode by `/`, join together again without the middle part, and replace `.php?id=` with `/` – Peter Apr 15 '16 at 12:53
  • You got it the wrong way around. Read the duplicate for an explanation of what `RewriteRule` does and the problem should become obvious. – deceze Apr 15 '16 at 13:14

0 Answers0