Jump to content

Simple, Url Re-Writing Problem


Eritrea

Recommended Posts

I have a page something like: www.site.com/ref.php/index.php?user=John

 

 

I need the above to be changed, to www.site.com/ref.php/john

 

I have .htaccess file in the root directory and inside it, there is this code:

 

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /url/index.php?username=$1

 

 

But when I browse the page: www.site.com/ref.php/john it is giving me a 404 error

 

it must be a simple mistake, because I totally know nothing about url re-writing.

 

thanks for the help

Link to comment
https://forums.phpfreaks.com/topic/269411-simple-url-re-writing-problem/
Share on other sites

To use the above you don't need .htaccess, all you need is in $_SERVER['REQUEST_URI'] (and $_SERVER['PHP_SELF']).

 

You might also want to use my snippet to clean PHP_SELF from the stuff from REQUEST_URI, as the latter can be used for XSS injections.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.