Porl123 Posted January 15, 2011 Share Posted January 15, 2011 I'm not really sure if this has anything to do with PHP itself, but I'm not at all sure how you'd do this. I often see profile pages on websites where the link to access them is in this format: http://www.website.com/profiles/user As apposed to: http://www.website.com/profiles.php?username=user I can see how you'd create the first method using GET variables, but how would the first work? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/ Share on other sites More sharing options...
President Obama Posted January 15, 2011 Share Posted January 15, 2011 Adding a redirect to your .htaccess file? Probably away to do it with php, I'm just to nooby. Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/#findComment-1159715 Share on other sites More sharing options...
Porl123 Posted January 15, 2011 Author Share Posted January 15, 2011 Aye, I know of a way to do it in the htaccess, but I'm trying to avoid it. D: It causes problems. Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/#findComment-1159718 Share on other sites More sharing options...
Porl123 Posted January 18, 2011 Author Share Posted January 18, 2011 Nobody have any idea? :x Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/#findComment-1161500 Share on other sites More sharing options...
Maq Posted January 18, 2011 Share Posted January 18, 2011 Yes, you have to add it to your .htaccess. I'm not very good with mod_rewrite rules but if you search this forum you will see examples similar to yours, it's a pretty common question. This may help: http://www.phpfreaks.com/forums/mod_rewrite/passing-additional-get-variables/ Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/#findComment-1161510 Share on other sites More sharing options...
iarp Posted January 18, 2011 Share Posted January 18, 2011 What errors are you getting with .htaccess ? When i was attempting to make something, i made use of wordpress' htaccess below, and then everything is grab-able with REQUEST_URI. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/#findComment-1161529 Share on other sites More sharing options...
Maq Posted January 18, 2011 Share Posted January 18, 2011 Aye, I know of a way to do it in the htaccess, but I'm trying to avoid it. D: It causes problems. Sorry, didn't see this post earlier. What problems? Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/#findComment-1161534 Share on other sites More sharing options...
strago Posted January 22, 2011 Share Posted January 22, 2011 Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^profiles/([^.]+)$ profiles.php?username=$1 [L] with the links pointing to domain.com/profiles/username if you're only getting there by a link, it shouldn't cause any problems. Now forums, they are harder set-up so they go to a URL like that. Quote Link to comment https://forums.phpfreaks.com/topic/224511-variables-as-directories/#findComment-1163448 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.