0

I want to get my data from url witch are slash separated like this:

www.example.com/page.php/12

witch must interpreted to:

www.example.com/page.php?id=12

I wont to specify page name like "page.php" in my .htaccess and it must be generic like "*.php". i use this lines but this change my baseUrl and my css are not accessible:

RewriteEngine On
RewriteRule ^([^/]+)/([^/]+)$  $1.php?id=$2
Cœur
  • 37,241
  • 25
  • 195
  • 267
Navid_pdp11
  • 3,487
  • 3
  • 37
  • 65
  • You don't need a rewrite rule for this as you can use `$_SERVER["PATH_INFO"]` to get the same `/12` in your code. – anubhava Dec 05 '16 at 09:41

1 Answers1

1

See RewriteCond to skip rule if file or directory exists: you should add conditions to not redirect requests to existing files:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)/([^/]+)$  $1.php?id=$2
Community
  • 1
  • 1
David Duponchel
  • 3,959
  • 3
  • 28
  • 36