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
https://forums.phpfreaks.com/topic/93120-page-variables/
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
https://forums.phpfreaks.com/topic/93120-page-variables/#findComment-477076
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
https://forums.phpfreaks.com/topic/93120-page-variables/#findComment-477115
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.