SennNathan Posted January 18, 2015 Share Posted January 18, 2015 Im setting up members on my site i want the profile url to be like www.mywebsite.com/NATHAN but not go to a folder on my server called nathan but instead go to mywebsite.com/?profile=Nathan Quote Link to comment https://forums.phpfreaks.com/topic/294030-how-to-redirect-url/ Share on other sites More sharing options...
Solution Ch0cu3r Posted January 18, 2015 Solution Share Posted January 18, 2015 (edited) You would use mod_rewrite for this. Have the following in a .htaccess file in your sites document root. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([\w]+)?$ index.php?profile=$1 Then output your links in the new format, eg $username = 'Nathan'; // users username echo '<a href="/'.$username.'">'.$username.'</a>'; // output link in the new format Edited January 18, 2015 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/294030-how-to-redirect-url/#findComment-1503328 Share on other sites More sharing options...
SennNathan Posted January 18, 2015 Author Share Posted January 18, 2015 That worked thanks Quote Link to comment https://forums.phpfreaks.com/topic/294030-how-to-redirect-url/#findComment-1503339 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.