tags:

views:

2560

answers:

6

Greetings.

I've been trying to grok regexes and rewrites but i'm a newbie at it. I have a simple site, one dir only, all i want is to rewrite domain.com/file.php?var=value to domain.com, making sure the user will only see domain.com in the adress bar throughout site navigation (even if i start making the site more complex).

Simply speaking it's freezing the url, although if the site grow's i'd rather make some "clean url" approach but i'm still at basic php and i sense i'd have to rtfm on http/1.1

+1  A: 

Typically this type of "clean" URL stuff is typically accomplished with a wrapper frame for the entire site. The browser shows the URL of that frame only, and the contents can be whatever.

But I actually don't recommend it, because the user may want to bookmark the "dirty" URL.

This type of URL obfuscation diminishes usability for advanced users.

Not to be a jerk, but I typically only see this type of URL obfuscation on "artsy" sites that care more about what their address bar looks like than usability of their site. Making your users happy via enhanced usability is a better long term approach IMHO.

Trampas Kirk
I guess that it was not the sites being "artsy", but just using Flash and don't knowing how to make changes in the Flash movie affect the url. It's quite tricky to do and requires javascript wizardry.
RommeDeSerieux
A: 

I guess freezing the url is driven by marketing desires, so here's the downside to that, from marketing standpoint as well: your users won't be able to send a link to a page they liked to their friends via IM, email or facebook, so it actually decreases the appeal of your site even for the most clueless users.

RommeDeSerieux
A: 

I don't (knowledgeably) think it's safe to have php variables showing around in the adress bar (although they'd show in the status bar of some browsers anyway...). Idealy the user wouldn't know what is the site using behind the scenes - i'm configuring error pages for starters. And yes, for aesthetics as well. If i can rewrite to domain.com/foo/bar i'd be happy; assuming nginx would handle the "translation back to ugly URLs" if it got such a request, which i think it does with location-directives. But having domain.com/file.php?var1=value&var2=value kinda annoys me, makes me feel i'm exposing the site too much.

Frames are not recomended (especially 'cos of search engines) and i'm trying to stick to xhtml 1.1 Strict (so far so good). If the content is well designed, easy to navigate, acessible regardless of browser-choice, intuitive, etc... i guess i could live with cute URLs :)

I'd gladly grok through any rtfm material regarding good webdesign techniques, php, http/1.1 and whatever made you go "Yeah! that's what i've been looking for!" at 4am.

Thanks :)

[if i understand this site right, this oughta be a reply to the original post, not to an answer... sorry]

RommeDeSerieux
A: 

You can use nginx rewrite rule like this:

rewrite  ^([^.]*)$  /index.php

to send all requests that do not contain a "." to your index.php script. In your php script, explode the request url to get the passed parameters, and then call the php page you want to:

#URL /people/jack_wilson
$url_vars = explode('/',$_SERVER['request_uri']); # array('','people','jack_wilson');
$page = $url_vars[1];
if($page == 'people'){
   $username = $url_vars[2];
   require('people.php'); #handle things from here.
}
Daniel Von Fange
A: 

You could also look into a PHP framework such as Code Igniter that will handle all the PHP side of this for you.

http://codeigniter.com/

Daniel Von Fange
A: 

Thank you all.