Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/229100-mod-rewrite/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/229100-mod-rewrite/#findComment-1181595
Share on other sites

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.