0

I'm new to web development but i know some php basic stuff. Using ftp, i create directories then create simple php scripts there, simple as echoing a string. Which can be accessed like,

www.sampledomain.com/folder1/subfolder2/hello.php

After some time, my friend introduced me to wordpress which is what they described as CMS. I tried to visit her site www.majaflores.com then i click on some stuff there and i noticed the url changed to http://majaflores.com/project/if-i-let-you-in-please-dont-break-anything/

At first, its pretty normal for me because its just a link where there is a folder named "project" and inside it another folder named "if-i-let-you-in-please-dont-break-anything". But when she showed me the ftp folders directory, i didnt see any folder named "project" under main folder of the domain. How did wordpress manage to do this? and how can i implement this manually?

cattarantadoughan
  • 509
  • 1
  • 6
  • 15
  • It's called url rewriting. There are no directories involved. Look up `.htacces` rewrite rules. Windows has a similar file called `web.config`. – Rasclatt May 02 '16 at 06:23
  • you mean i can create a virtual folder using .htaccess? okay gonna check it – cattarantadoughan May 02 '16 at 06:29
  • Yeah sort of. You feed it that url and the site translates it to something like `www.example.com?section=project&title=if-i-let-you-in-please-dont-break-anything` then the database pulls up that row with those criteria. – Rasclatt May 02 '16 at 06:30

2 Answers2

1

This is they way WordPress stores data. U can further see the setting under Permalink.

Under Permalink, u can have options to render ulr as page id, category names and more. You can also use your own format over there.

Just a note, WordPress stored data in database not as a content on FTP directory.

Harry
  • 306
  • 2
  • 10
1

Just wanted to say that like most server-side code environments, PHP also let you parse URLs "manually" and decide what to do accordingly, be it return a file or generate some content.

You can find more information about how PHP is parsing URLs in here:

http://php.net/manual/en/function.parse-url.php

and some discussion regarding it in here:

URL handling – PHP vs Apache Rewrite

Community
  • 1
  • 1
Itai Bar-Haim
  • 1,686
  • 16
  • 40