Jump to content

Page Variables


gtal3x

Recommended Posts

Hello,  i understand how to pass variables throu pages and how to get the data that you need from them from sql database. What i dont understand is how to make this variable:

somesite.com/users.php?username=John

to work like that:

somesite.com/users/John/

or even like:

somesite.com/users/John.html

I have seen this many times in different sites, but dont know how they do this, if you can explain to me or give me a link for an understandable tutorial i will appreciate it! Thanks 

Link to comment
Share on other sites

This isn't a php thing, its an .htaccess thing (part of apache servers. If you are using a windows server, I don't know how its done).

 

Google mod rewrite, and there are tutorials and forums all about how to rewrite URLs (which is what you want to do).

Link to comment
Share on other sites

Well with this it isn't even php this has to do with your apache .htaccess files.

 

There are ways to do this but I'll go with the easiest way... This is for apache httpd

 

Create a file in your website main folder... the base folder called .htaccess

 

Within the file, type the following

 

RewriteEngine on
RewriteRule ^/users/([^/\.])/?$ users.php?username=$1

 

this should help you out

Link to comment
Share on other sites

So it worked then ?

No because i dident try it. Basically I am starting a site now, and i wont to make the links look that way, the reason i posted this question was so i know, how should i write my links in the script, like you guys told me there is a mod_rewrite, or making a htaccess, so now i will make the site with normal links (if i understood right), and at the end just do the things you told me and it should work...

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.