Twistedweb123 Posted February 28, 2011 Share Posted February 28, 2011 I'm new to mod rewriting techniques, so this is a little advanced for me, but very easy for anyone with experience. Basically I am making a website, where i want to give users their own directory upon signup through mod rewrite. so rather than: mysite.com/users.php?username=xxx They can visit mysite.com/xxx I havnt written the code yet, but im pretty sure I can manage that. The trouble I am having is as follows. Basically, within their username, I want them to have a profile (similar to facebook) in the style that you can click photos, view a small bio, events they are hosting etc. So I want to turn (example:) mysite.com/bio.php?username=xxx mysite.com/photos.php?username=xxx mysite.com/events.php?username=xxx to mysite.com/xxx/bio mysite.com/xxx/photos mysite.com/xxx/events any help will be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/229100-mod-rewrite/ Share on other sites More sharing options...
Twistedweb123 Posted February 28, 2011 Author Share Posted February 28, 2011 bump Quote Link to comment https://forums.phpfreaks.com/topic/229100-mod-rewrite/#findComment-1180931 Share on other sites More sharing options...
kirill578 Posted March 1, 2011 Share Posted March 1, 2011 try this: RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z0-9]+) users.php?username=$1 RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ $2.php?username=$1 Quote Link to comment https://forums.phpfreaks.com/topic/229100-mod-rewrite/#findComment-1181335 Share on other sites More sharing options...
Twistedweb123 Posted March 1, 2011 Author Share Posted March 1, 2011 Unfortunatly the above code didnt work, as the server always looked for the users.php file, no matter was was entered. However I hve fixed this myself. I had a little play around, and im not sure how dity this code is, but it works for me RewriteEngine on RewriteRule ^([^/\.]+)/events/?$ events.php?artist=$1 [L] RewriteRule ^([^/\.]+)/tours/?$ tours.php?artist=$1 [L] RewriteRule ^([^/\.]+)/photos/?$ photos.php?artist=$1 [L] RewriteRule ^([^/\.]+)/videos/?$ videos.php?artist=$1 [L] RewriteRule ^([^/\.]+)/bio/?$ bio.php?artist=$1 [L] RewriteRule ^([^/\.]+)/fans/?$ fans.php?artist=$1 [L] RewriteRule ^([^/\.]+)/related/?$ related.php?artist=$1 [L] RewriteRule ^([^/\.]+)/?$ $1.php [L] As you can see, if manually entered the files which the user will have a url for - photos, videos, bio etc. I have then written a rewriterule for all files to be accessible in the server as mysite.com/xxx Quote Link to comment https://forums.phpfreaks.com/topic/229100-mod-rewrite/#findComment-1181595 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.