Jump to content

Variables as directories


Porl123

Recommended Posts

I'm not really sure if this has anything to do with PHP itself, but I'm not at all sure how you'd do this. I often see profile pages on websites where the link to access them is in this format:

 

http://www.website.com/profiles/user

 

As apposed to:

 

http://www.website.com/profiles.php?username=user

 

I can see how you'd create the first method using GET variables, but how would the first work? Thanks

Link to comment
Share on other sites

What errors are you getting with .htaccess ?

 

When i was attempting to make something, i made use of wordpress' htaccess below, and then everything is grab-able with REQUEST_URI.

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Link to comment
Share on other sites

Options +FollowSymLinks +Indexes

RewriteEngine on

RewriteBase /

RewriteRule ^profiles/([^.]+)$ profiles.php?username=$1 [L]

 

with the links pointing to

 

domain.com/profiles/username

 

if you're only getting there by a link, it shouldn't cause any problems. Now forums, they are harder set-up so they go to a URL like that.

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.