Reputation: 1862
Here is my page
xyz.com?show=page
Inside my index.php the code will be like
<?php
echo $_GET['show']
?>
But i want users to type only xyz.com/page
and it should automatically append ?show
in url
How can i do this ?
I have .htaccess like
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
But it removes only the last part of page i.e., .php
How can i do this
Upvotes: 1
Views: 1743
Reputation: 24413
If index.php
will be handling all your requests, you need to rewrite them index.php
. What you're doing now is rewriting them to the current request and adding a .php
at the end.
This should do what you want:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ /index.php?show=$1 [NC,L]
Upvotes: 1