Eritrea Posted October 13, 2012 Share Posted October 13, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/269411-simple-url-re-writing-problem/ Share on other sites More sharing options...
requinix Posted October 13, 2012 Share Posted October 13, 2012 Is ref.php a PHP script or a directory? Quote Link to comment https://forums.phpfreaks.com/topic/269411-simple-url-re-writing-problem/#findComment-1384922 Share on other sites More sharing options...
Eritrea Posted October 13, 2012 Author Share Posted October 13, 2012 ref.php is a dispacher, file, it has included files inside it, for example, if ref.php?user is the case, the the GET function, gets user id and outputts data from mysql Quote Link to comment https://forums.phpfreaks.com/topic/269411-simple-url-re-writing-problem/#findComment-1384956 Share on other sites More sharing options...
Christian F. Posted October 13, 2012 Share Posted October 13, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/269411-simple-url-re-writing-problem/#findComment-1384990 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.