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


How to "folder forward"?





moejoe
Hi!
Im sure everyone here has seen how myspace and various other websites 'folder forward'

When i say that i mean that the end user of the site enters a URL like "myspace.com/frihost"

And that forwards to they're user page!

How can i achieve the same functionality using PHP?... thanks!
alalex
For this you must use .htaccess and mod_rewrite.

I'll assume you don't know about this and I'll explain the whole thing to you:

First create a test file, and paste the following lines in it:
Code:
# this is the initialization
Options         +FollowSymLinks
RewriteEngine   On

# these are the rewrite conditions
RewriteCond     %{REQUEST_FILENAME}     !-f
RewriteCond     %{REQUEST_FILENAME}     !-d

# and finally, the rewrite rules
RewriteRule     ^([a-zA-Z0-9\-]+)/?$    /profile.php?user=$1 [L,QSA]

In it, you should change the last line, where it says "profile.php?user=" to whatever profile page name you have. Then the ?user= is the get variable that tells the profile page what profile to display.

Once you are done, rename the text file to ".htaccess" just that, and upload it to the root directory, and you are good to go Wink
rvec
or you could put a php file in the dir with this in it:
Code:
<?php
header('Location:http://www.example.com');
?>

Just in case the .htaccess isn't allowed on your host (it is on frihost).
moejoe
II would do the header php trick, but that'll mean potentially hundreds of DIR with member names flooding my server. I wouldnt want that.

I just want to get a kinda virtual folder forwarding.

I know a little about .htaccess could you elaborate more on it?

thanks
ashok
You can get a lot of information from the official Apache page...
alalex
There is a very good website explaining all about .htaccess:
http://www.crucialwebhost.com/blog/htaccess-apache-rewrites-oh-my/

It explains all about redirects and mod_rewriting
Related topics
public_html folder
Can't delete module folder from postnuke?
Battlefield 2
PHP Image Upload (MySQL/Folder)
uploading files through web browser
how to upload a folder?
Cron Folder Backup
Invisible folder!!!!!
Windows Tips&tricks!
(official) Firefox & Thunderbird 1.5 Beta2 Now Available
Lock Folder XP 3.6
Shortening URLs
Second FTP account [Resolved]
do i need to upload the whole folder or only the content
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.