I have written (in PHP
and PDO
) a link shrinker that works with the GET
method (index.php?id=1)
but I want it like this: domain.com/[ID]
.
Asked
Active
Viewed 1,347 times
-5
-
1http://stackoverflow.com/questions/11696718/htaccess-rewrite-book-phpid-1234-to-book-1234 – schellingerht Mar 29 '16 at 09:33
-
Read up on URL rewriting. That's what you seem to be looking for. But how you must implement it depends on which web server you are using, so this question is missing details for a proper answer. – Oldskool Mar 29 '16 at 09:33
1 Answers
0
create .htaccess file in your main folder and write the below content inside the file
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+)$ index.php?id=$1 [L]
Result
domain.com/1 = domain.com/index.php?id=1
domain.com/home = domain.com/index.php?id=home
domain.com/ID = domain.com/index.php?id=ID

J.K
- 1,382
- 1
- 11
- 27