Getting values in php while using .htaccess RewriteEngine Rule
I am using the following rule
RewriteEngine On
RewriteRule ^([^/]*)$ page.php?title=$1 [L]
It means it will create a page like view
(i.e.,)
www.mywebsite.com/contact
www.mywebsite.com/blog
But how can i get values that is passed in the url and display it inside the page using Get method echo "Page content is ".$_GET['title'];
While i pass the value in the url like www.mywebsite.com/view,
It is just displaying > Page content is page.php
What mistake i am doing and how can i fix this ?
Some urls that don't need to be rewritten are getting rewritten. You probably want to change your rule like this:
RewriteEngine On
RewriteRule ^([^/.]+)/?$ page.php?title=$1 [L]
[^/.] ensures that there is no dot in the path+ ensures that there is at least one character/? allows an optional trailing slashIf 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