Friendly subfolder link to page (wikipedia style) - php

I am struggling to find this as I'm not sure exactly what I'm looking for!
I've seen that some sites seem to use 'subfolders' as links to pages, e.g. wikipedia.
E.g. Let's say I had a record in a database with a unique title "My Shopping List". I want to be able to navigate to www.mySite.com/my_shopping_list and have it automatically 'forward' to a page showing the relevant record.
I am using IIS and wondering if there's a way I can do it with that, but I may be looking in the wrong place.
This is for a knowledgebase where I might write an article called "how to use a computer" and would like to be able to create a 'friendly' link for users (http://www.mySite.com/how_to_use_a_computer rather than http://www.mySite.com/article.php?ID=123. I will need to be able to create these 'links' dynamically using the title field.
Thank you
EDIT: I am using IIS6

You should use URL Rewrite, the microsoft ressource for this technique is here: http://www.iis.net/download/urlrewrite
In the iss forum the issue about url rewrite in iss < 7 is discussed with some suggestions on software to use.
I don't know which one is best, maybe there are others who know:
http://iirf.codeplex.com/
http://www.isapirewrite.com/
http://urlrewriter.net/

With PHP, you'll need to code URLConf using something like a htaccess file or the manager GUI. You can read ISS docs on URL rewrite to learn how., but as I understand, this is a module you'll have to download separately.
This question also shows how do do it without editing server configuration files or htaccess, but you'll be stuck with a http://example.com/index.php/path/to/view format (where index.php is a real script with the URLConf in it.)

Well some time ago it was used to call 'Friendly URL' or 'FURL', now i see that it's ust Rewrite URL. Look for tutorials for beginners.

Related

PHP Pagination Confusion

I'm not asking for a whole engine of code. I'm working on a blog/magazine website. Here are the 2 styles of paginations. I see people use these types of addresses:
example.com/browse?page=100
example.com/page/100/
I understand 1.'s. But, 2. doesn't give me an impression of php usage in the address.
I did a search on Google, but there are only helps on 1. How do you manage 2.? Because whenever you write a new article, you have to push the content throughout every html? Did they use "fake addresses"? because I tried example.com/page/100/index.html and there is no such website.
Can anyone point me to a webpage or explain to me how did they manage 2. style of pagination? Which has a better UX?
Sorry if this is a bad title. Please help me edit and ask me if anywhere isn't clear.
It's URL Rewriting that is responsible or translating nice-looking Urls to their 'real' path on the server.
In your case,
www.example.com/page/100/
might be rewritten on the server to something like
www.example.com/browse.php?page=100
More info:
mod_rewrite for Apache
Url Rewrite for IIS

PHP - Getting information from link itself rather than GET parameters?

Consider a situation of a URL as:
www.example.com/softwares/download.php?f=firefox&v=13
It does not look as good as URL:
www.example.com/softwares/firefox/download?v=13
or same download.php used as:
www.example.com/softwares/chrome/download?v=20
How can I achieve this type of URL filtering in PHP?
Some point I want to covered here:
I don't need a folder-hierarchy here like having different folders for /firefox/ and different for /chrome/
There could be only two PHP files (as I wish to) for all products: /software/software-info.php and /software/download.php (already got here).
I am able to put and fetch information from database in PHP but just want to have different link for different product.
I am a Java Web Developer in which you have Filters to get information from a part of link and redirect the request accordingly.
I am new in PHP programming and if this question is already asked or obvious than please pardon me and provide that question link.
This is ideally what you should use url rewriting (mod-rewrite in .htaccess) for.
Your visitor navigates to:
www.example.com/softwares/firefox/download?v=13
or even
www.example.com/softwares/firefox/13/
but your server will understand it as:
www.example.com/softwares/download.php?f=firefox&v=13
You can use htaccess files to do URL rewriting. Essentially this would allow you to take the segments of the url after /software/ and pass them ass parameters to be controlled by the software script.
There are also a bunch of PHP frameworks which use 'routes'. They're based on a similar principal as URL rewriting. I'd recommend Codeigniter as a good starting point - it's a straightforward framework, which plenty of documentation and tutorials.
Good luck!

PHP CMS web page short URL?

I am buildiig a simple CMS and would like to know how to create short URLs (not the APACHE bit but the PHP bit).
example.com/?page=100
example.com/home/test
How would I interpret the ?page=100 into /home/test (Through select the database, but i couldn't figure out how) I can see if just one level /home/test because you probably can have a zoneID, but when it comes to /home/test/test. I become lost
And how do I parse back the /home/test to the page id.
Plus is there anyone can show a bit idea for the database design as well?
These resources can be useful to you:
https://stackoverflow.com/a/120411/370290
http://www.symfony-project.org/book/1_0/09-Links-and-the-Routing-System
http://codeigniter.com/user_guide/general/urls.html
http://www.phpaddiction.com/tags/axial/url-routing-with-php-part-one/
You need some kind of mod_rewrite for your server side.
That will help you to send route data to index.php (or somewhere else) file without filename in adress string. Than some php file will analyze the route and give correct html.
ok i think you need to definitely need to look at the way you are going to do your routing (through mod_rewrite)..for example
1.you can rewrite the page www.example.com/test to ..www.example.com/index.php?page=test and implement a way of getting page by the page name..and returning an id if a page name exists ..if multiple entries exist then maybe the last modified will be given precedence over the otheers ..you can get the following book CMS Design Using PHP and jQuery helped me alot

how to tell if a site is made with cakephp

can you tell if a site is made with cakephp, how,
how to check it - to check any folders, initial pages , to see some specific queries ?
Maybe this CMS detector can help you. HTTP headers in many cases reveal a lot about technology used to power a site.
1) find a form on it, if it has values in the format data[Something][whatever] chances are its cake
2) url format is normally /something/anotherthing/id and a lot of times there will be some urls like /pages/something, also wont often find extentions in the url
3) check the name of the main css file, some people wont change it, cake.default.css iirc
4) try going to a random url and see what the error looks like, default cake will be something like "Error: The requested address '/sdfsdfsfsd' was not found on this server."
5) if the url is site.com/something/etc and you can go to site.com/index.php?url=/something/etc
obviously these can all be done on any system, but its a pretty good giveaway if the all/mostly work
You can use WhatWeb which is created for this purpose and has a plugin for cakephp.
You can use the tool I made called PageXray, it can detect CakePHP apps.
http://pagexray.com
It uses some quick Curl techniques to check if files exists, if some css or images are in webroot and also checks the page's header for some CakePHP signatures.
Then for a list of sites that was made with cakephp, check this out.
http://pagexray.com/technologies/php_cakephp.htm

Create Pages Automatically

Is there any method in Php by which I can create a page automatically based on a predefined template. Like if we create a new post in blogger it automatically creates page for that post with the name of that post, like this one:
http://learntoflash.blogspot.com/2009/12/exit-button-in-flash.html
Here Exit Button In Flash is the name of my post I have written and an automatic page is created for it.
Or like here on this website if we ask a question it automatically creates a page for that question. I want to know can I achieve this in Php or anything close to this ?
...here on this website if we ask a question it automatically creates a page for that question.
It sounds like you may believe an actual file is created when you post a question. My bet would be that this page is generated via the question id in the URL.
The only files created would be cached output, which may or may not resemble actual HTML pages.
You should use URL rewriting. This Apache module lets you define rules to rewrite web addresses in your desired way.
The process to make your web application ready for this, is not a short story so you should read more about it.
This article is a good starting point:
http://articles.sitepoint.com/article/guide-url-rewriting
This is acheived by using mod_rewrite. A good place to look for inspiration is the .htaccess used in Wordpress.
to something like that you have to grasp the very fundamental in php or any programming language at all, i mean the core of php is to create dynamical generated pages based on user/browser input.
You might need to take a quick tutorial about php might I suggest http://www.tizag.com/phpT/
good step for step tutorial
Edit:
if you're wondering how the websites seems to have created a html page for every question, the answer would be they're not they are probably using mod_rewrite as mentioned before to rewrite to url to print a little more user friendly url, the actual url could be something like this https://stackoverflow.com/index.php?post=4499289 in reality

Categories