View Full Version : How to change ?news=main&title=my%20title to /news/my%20title

08-02-2007, 10:56 PM
Hy all.

I'm new to PHP, and i built my first class template. Basicly it switches content by get variables main and title

Main is array of mostly main titles like Index, News, (i haven't reached to contact yes, couse i don't know how to include file, depending on get) but that's the first part.
Now when user reaches for index (or just visits the site) another menu is set, which is array of index Titles, and Paths.

Now ugly part is how can i change url in top, from ?main=news to just /news, and let's say ?main=news?title=My news title to /news/mynewstitle

Is this maybe .htaccess question?

08-02-2007, 11:02 PM
yes it is! It is a mod_rewrite question actually. There are many examples of how to do this type thing if you search Google for example.

The Apache HTTP server has a rewrite engine called mod_rewrite, which has been described as "the Swiss Army knife of URL manipulation". A simpler module, mod_alias, allows for simpler rewriting. **From wikipedia (http://en.wikipedia.org/wiki/Rewrite_engine), this has lots of good links to look into it further.

"You cannot escape the responsibility of tomorrow by evading it today." Abraham Lincoln
Company (http://www.emblemsoftware.com) Projects ( Microstock Image Search (Search Dreamstime, Fotolia and other agencies from one site) (http://www.safepix.net))

08-02-2007, 11:08 PM
Does it lower the performance of the webiste?

08-03-2007, 12:07 AM
Ok, i figured it out.

If you request eg /?main=index, you cant change it to /index. But you can then use /index to go to link to /?main=index. So that means, if i used PHP script to create links like this href="?main=index", i have to change them all to href="index", but GET will then use rewrite condition of /index, and parse it like ?main="index".

Am i right!?