Reputation: 1808
This may be a duplicate but I have looked all over with no success and I have a website where a person enters a string into the $_GET
of the URL (i.e. /index.php?w=string
)
And I have my $string = _GET['w']
variable
But my question is I want to know if it is possible to rewrite the .htaccess file so that it will display instead of /index.php?w=string
to just /string
and then the $string
variable can still be filled with that
Upvotes: 0
Views: 2244
Reputation: 13128
You could do something like this in your .htaccess
file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?w=$1 [L,QSA]
That would allow you to access the url like: http://www.example.com/string
Thus allowing you to access your $_GET['w']
and display the relevant page/content however you please with some SEO friendly URL's.
Upvotes: 3
Reputation: 651
You can do something like this in your .htaccess
file:
^/(.*)$ /index.php?w=$1
Upvotes: 0