I've spent a couple of hours trying to achieve something I thought was easy. I have http://localhost/testing_url_document/second.php?id=2
and want to turn it http://localhost/testing_url_document/second/id/2
. I have achieved to remove the php extension but stucked into the rewriting the site page . In the htacces i have followed the following procedure.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
this is my index page
Index.php
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
// put your code here
?>
<a href="second/id/2">click here</a>
</body>
</html>
Second.php
<?php
echo $_GET['id'];
?>
The second.php should gets the value 2
Thanks in advance for help.
Have it this way inside /testing_url_document/.htaccess
:
RewriteEngine On
RewriteBase /testing_url_document/
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^./]+)(/.*)?$ $1.php$2 [L]
RewriteRule ^([\w-]+(?:\.php)?)/([\w-]+)/([\w-]+)/?$ $1?$2=$3 [L,QSA,NC]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With