0

Hi,

I'm working on one php project without using framework and I want to form nice urls without tons of get parameters and ? and & characters. I know this could be solved in zend using controllers and actions and I'm looking for somerhing simillar.

On my site, I have faculties, now when somebody open one faculty to see information, it should be mysite.com/faculty.php?id=6 for example, and then faculty with id=6 is shown.
I'd like this url to be mysite.com/faculties/faculty_name (for example). Also, when user opens list of faculties, url should be mysite.com/faculties indstead of mysite.com/faculties.php. Is only way I can do this by putting special folder faculties and index.php to show all faculties. And maybe when someone opens one faculty, it should be
mysite.com/faculties?ref=6 for faculty with id 6. This is much better than faculty.php?id=6.

How can I do this best, with less code and less folders?

Thanks in advance,

Amer

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by aldm
2

You can do this by htaccess.
This is a file named '.htaccess' which you have to put at root of your required project.
You have to write rules in htaccess to generate url.

Visit http://www.generateit.net/mod-rewrite/ to generate simple rules.

Edited by vibhaJ: n/a

Votes + Comments
cracking link. cheers :)
0

Thank you for your answers.
I found a great tutorial about this topic on

http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/comment-page-2/#comment-369468

But how can I handle more get parameters in query string using nice url. How can I know which parameter is for example cost etc. For example, I want to buy a house and search for them. Search parameters can be: cost, garage, city, number of rooms etc. Now if I want houses that have a garage in London nice url should be

www.mysite.com/houses/city/London/garage/yes which means
www.mysite.com/houses.php?city=London&garage=yes

Is this best way to solve this?

Thanks again for your answers.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.