FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Give each user a sub directory?





Slammer
Hey. Before i started, ill just say this is NOT for giving hosting to other people from my account, this is for a piece of blog software im working on. I want to be able to setup so each user can have a sub-dir redirect to their blog. ( eg http://example.com/usernamegoeshere/) I want this to do be done dynamically (obviously). I would prefer the directories didnt exist, and it works as a redirect to a script that displays the corrent content by getting the user name from the url. But how would i go about doing this?

I hope you understand what i mean. Im not sure if this is the correct place, please move to scripting help if it isnt, although i thought it should go here as im not sure if this is possible with the current server setup, might require some custom apache config. If so then how would i go about configuring apache for this for my other own private server.


Hope someone can help
Thanks
Slammer
ocalhoun
Have the index file in each subdirectory include your script perhaps?
Slammer
ocalhoun wrote:
Have the index file in each subdirectory include your script perhaps?


You obviously didnt fully read my question. I dont want to have all the directories physically there. But i want to keep the url as if there is. But the script is called instead.
mathiaus
Yes this is possible. I would suggest using a .htaccess files with the contents below
Code:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon
RewriteRule ^.*$ - [F]
RewriteRule ^blog/(.*)$ /blog.php?name=$1

What this will do is redirect any url such as
http://yourdomain.com/blog/mathiaus
OR
http://yourdomain.com/blog/slammer
to the file blog.php with the username in the url, without creating the sub dirctory blog or the persons name. This can be taken with the below
blog.php
Code:
<?php
$name=$_GET['name'];
header("Location: http://www.,mathiaus.com/blog");
?>


I'd give you more but I'm not sure how you're getting the persons blog url Confused

moved to scripting as well Wink
Slammer
Thanks a lot for your great answer Smile Exactly what i was looking for!

Cheers
Slammer
Related topics
Basic Search Engine Optimizing
FTP problems --> Use Filezilla and/or active mode
Creating an RPG bot in IRC (yes I wrote this)
writing COM components in Perl
10 things you should know about every Linux installation
How can i restore data encrypted in winxp?( 50 FRIH$ )
Login System Tutorial Part 1 Creating Registration
General .htaccess tutorial.
Will work for FRIH$
Anonymous Posting
php gallery
Create a Flash Contact form, sends to your email account
Two sub-domains?
User Accounts
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.