Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.