Reputation: 533
I want to write <a href="product.php?id=5">
as product/5.I am not talking about user to type doamin.com/product/5 to get the result, what I am looking for is- when user click the link, the browser address bar will show the url as domain.com/product/5.
Is it possible?Any help would be greatly appreciated.Thanks in advance.
Upvotes: 1
Views: 274
Reputation: 23610
Just write:
<a href="/product/5">LINK</a>
What you also need is a .htaccess file, that handles mod_rewrite, for example:
# turn mod_rewrite engine on
RewriteEngine On
# rewrite all physical existing file or folder
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
# allow things that are certainly necessary
RewriteCond %{REQUEST_URI} "/css/" [OR]
RewriteCond %{REQUEST_URI} "/images/" [OR]
RewriteCond %{REQUEST_URI} "/images/" [OR]
RewriteCond %{REQUEST_URI} "/javascript/"
# rewrite rules
RewriteRule .* - [L]
RewriteRule (.*) index.php?_route=$1 [QSA]
With you'll get a $_GET['_route'] which's value will be /product/5. The rest is up to your php code to parse that string.
Upvotes: 2