Jump to content

URL


jaymc

Recommended Posts

I have a profile page that knows which user to grab data for via the GET

 

www.site.com/p.php?user=fred

 

What I want is to use this approach

 

www.site.com/fred

 

In this case surely I would have to have a directory called fred and some kind of code in there to pick up that where looking for fred..

 

However, I know sites that use this method and Im pretty sure they dont have 300,000 member directories

 

Is there a way around it? I have full control over appache by the way

 

maybe a virtual host with the servername of profile.site.com?user=

 

Not sure how I can do this, feedback would be great

Link to comment
Share on other sites

edit your .htaccess file and use the following:

 

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ p.php?user=$1 [L]

 

That works, but, any other link I go to on my page directs to p.php

 

For instance I have www.site.com/messages

 

Its taking them to p.php and treating it as this URL www.site.com/p.php?user=messages

 

How did I get around that?

Link to comment
Share on other sites

I dont want to have www.site.com/users/username

 

I want to just have www.site.com/username

 

But, if I have a script inside of a folder called files, it thinks www.site.com/files is a username called files

 

I dont think its going to be possible, however, im sure faceparty do it!

 

Anyway, how about www.membername.site.com instead, how can that be achieved through rewrite rule?

Link to comment
Share on other sites

don't use www

 

Do you know see the issue that I brought up?

I mean, what if you have a user called files? How do you know which they want to get to.

You can do site.com/username if you make sure all of your other urls are within another directory. But otherwise there is no way to tell what is what.

Link to comment
Share on other sites

Hey Ive ran into a new problem

 

members.site.co.uk/username works fine

 

However, some of my members names have weird characters in them, even something as simple as a fullstop is causing a problem

 

members.site.co.uk/.my.name.

 

I get page cannot be displayed

 

Any ideas?!

Link to comment
Share on other sites

Also, my new way of using a subdomain as members.site.com/username

 

How about the original way site.com/username, but, have something that looks to see if thats an actual directory first... or if that member exists or not

 

Just wondering how to go about that...

 

How do myspace do it? because they have directories in there top level...

 

 

Link to comment
Share on other sites

I highly recommend reading this tutorial on mod_rewrite: http://www.easymodrewrite.com.

 

For example, you can do exactly what you want to do with this htaccess code:

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*) p.php?user=$1 [QSA,L]

 

This essentially tells Apache and mod_rewrite to first look if the file exists. If it does not, run it through p.php.

Link to comment
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.