Cup of Java
Cup of Java

Reputation: 1808

Removing Question Mark and Equal Sign from URL php

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

Answers (2)

Darren
Darren

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.

More Reading

URL Rewrite for beginners..

Introduction to URL Rewriting

Upvotes: 3

NinGen ShinRa
NinGen ShinRa

Reputation: 651

You can do something like this in your .htaccess file:

^/(.*)$ /index.php?w=$1

Upvotes: 0

Related Questions