changing url name and what file it points to in php - php

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?

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

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.

Related

Is it possible to implement virtual path in PHP-

I am using PHP script to set up a website which sells book.
Let say my website is hosted at www.sell-book-example.com.
I want to allow accessing to a book detail page by navigating to www.sell-book-example.com/book/2121.html where 2121 is the book id.
Keep in mind that book/2121.html should not exist in the document root of the web server.
As in I do not want to pre-create many book detail pages in a book folder.
I have checked some other website which are able to do that with PHP.
If anyone can provide me some sample or link, that would be great.
Thank you.
This approach is known as Dynamically generating of pages by php scripting.
You have to create a script.php file where your dynamic code will be scripted and from the url you have to catch the code and according to the code you have to generate the book detail page. All this should be done by scripting.
The url will be like these
www.sell-book-example.com/script.php?id=2121
www.sell-book-example.com/script.php?id=2122
www.sell-book-example.com/script.php?id=2123
This urls will not show in website. To make it pretty as you need like
www.sell-book-example.com/book/2121.html
You have to redirect in .htaccess file i.e. to map the urls.
For example if some one is trying to call www.sell-book- example.com/book/2121.html url than internally it will be call www.sell-book-example.com/script.php?id=2121 url and produces your book details page of 2121.

How to read subpages on server?

Can I get a list of files on any page?
For example on page
www.90minut.pl/
Every news on page is in folder "news" eg.
www.90minut.pl/news/238/news2387307-Deniz-Yilmaz-nie-zagra-z-Legia.html
I would like to see all files on
www.90minut.pl/news/
Is it possible in PHP?
No.
Unless the site provides you with links, there is no way to tell what resources it is hosting.
of course you can, but, you have to pay attention if the structure from the website/system is using structure like MVC or it's using friendly urls, and the server's permission it's setted as read mode or read/write.

What is the file path of the main page (home) of a Magento store?

I need to locate the file that manages the main page of my online store developed with Magento (which would be the index.html). I just need to change a link, and I've used Firebug shows that the file i need to edit is "misitioweb.com" (the main page) but the document itself does not appear in the ftp. The initial page consists of a bunch of XML, and PHP's PHTML. If someone wants to see the address page is http://peluches-cel.com and only want to change the destination URL of the link "Peluche del mes". I have used the help of Magento to show "Help template route" and I downloaded the 4 files that are more likely to manage that area of the page, but I can not find the part where specify the destination URL of the link. I have always worked with HTML or PHP separately (I have little experience with PHP) and I find it very difficult to understand how Magento builds each website. If someone could give me a little hint on how to achieve change that link would you do me very happy, it took a long time trying it on my own and looking online but can not find how to do any guestbook or forum that explains how to work well with Magento, in my language, there are hardly any documentation on Magento, so I decided to try my luck in this forum and I've read on several pages that involves many professionals in the e-commerce. Thanks in advance to all who devote their time to read my question.
I don't really understand what you want.
But if you want to change the base URL, you can do that by accessing database via phpMyAdmin, find the table core_config_data and change the URL in the web/unsecure/base_url and web/secure/base_url to what you want.
Not the url of the page, but the url of a link. Try clicking on "Peluche del mes" and see what comes out, gives access to http://www.peluches-cel.com/peluche-del-mes, I want access to http://www.peluches-cel.com/oso-tiziano-2col-40cm directly. The problem is NOT EXISTS peluches-cel.com/oso-tiziano-2col-40cm page on FTP, to be done in PHP there are different functions that are responsible for creating it at the time of the request I need to change the link to "Peluche del mes", if you see with firebug or any other source code analyzer, the source code of the page you will see that line 146 is managed that link, but I can not directly access the code ¿do you understand me? through an ftp client no such file or html as php magento works with the model view controller, that's my problem. Thank you again.

Creating dynamic subdomain using PHP Custom CMS?

I am somehow confused to analyse a project. Client says "I need an admin panel using PHP that create subdomain on wizard", i.e like he wants www.domain.com/sub1, www.domain.com/sub2, www.domain.com/sub3 etc. each sub domain may contain different header, menu, content, footer etc. I am really confused in "How do I make PHP admin panel that creates a directory and files for each subdomain?". I hope you got it, otherwise I am ready to discuss it more.
Thanks.
Hope you have something on this:
http://php.net/manual/en/function.mkdir.php
http://php.net/manual/en/function.fwrite.php
Why making a directory for each "domain"? You can use .htaccess and a database.

How can I do this with page redirection?

I have a revision website, it has stuff for multiple school subjects. I am starting to develop subject pages, these will have stuff only for that subject. e.g. a physics page
Anyway, what I am trying to do is let people type in www.myWebsite.com/history or www.myWebsite.com/ict - or what ever. And them get redirected to the appropriate page.
From that it sounds really simple, I would just put a file called history.php in my public_html home directory, right?
But my home directory is super organised, with everything in nice sub folders. I want to but all the subject pages in a sub folder called 'subjects' (imaginative name :p ).
How can I put these pages in the sub folder, yet still let the user access them from the URL examples above?
A great way to do this is to use a Front Controller. You can re-route all requests to one file (typically index.php) via htaccess and then from there grab the URI (the /itc, /history etc.) and use it to direct the request to the appropriate script.
Check this out, should get you started.
http://www.technotaste.com/blog/simple-php-front-controller/
Once you figure that out, you will want to compare the differences between dynamic and static invocation. Cheers.
you've got to do a url rewrite for the same. google out mod_rewrite and you'll get the examples.
If you are running under Apache, mod_rewrite is probably the most direct approach to accomplishing this.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
Basically create a .htaccess file in the root that maps the URI segment to the appropriate php file in your 'subjects' directory.
I think this is a case where you could use mod_rewrite, so the web server you're using will redirect the user to the appropiate directory. You can either keep the rewrite list manually or dynamically using regexes.

Categories