Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » .htaccess URL rewrite

Credits go to BAF, CGamesPlay, Matthew Leverton, Thomas Fjellstrom, and X-G for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
.htaccess URL rewrite
Matthew Leverton
Supreme Loser
January 1999
avatar

Each sites' vhost has an Alias from /.dispatcher.php (which doesn't exist) to /var/www/cms/site/dispatcher.php. That's the only kind of link between the two. That main dispatcher handles everything via the classes that sit in the cms/class directory.

Vanneto
Member #8,643
May 2007

Haha I'm so lucky this thread isn't dead yet! ;D Time is of essence.

So, I still don't get it. What if there is no parameter in Request->path? What does a module show then? Index.tpl? This is now bugging me for some time and I just can't seem to get it yet... My brain is hardwired with page-based thinking! :P

In capitalist America bank robs you.

Matthew Leverton
Supreme Loser
January 1999
avatar

Use whatever method that makes you happy inside. For me a path like /foo/bar/blah?z=y would look like (in JSON):

{
  path: ['foo', 'bar', 'blah'],
  params: {z: 'y'}
}

A path like / just becomes:

{
  path: []
  params: {}
}

I don't treat it as a special case. If nothing implements the empty request, then a 404 would be triggered just as if someone went to '/asdfsadfasdfasdf'.

So you could create a Module_EmptyRequest if you wanted. It could just load index.tpl.

I always load Module_AutoTemplate as the last, catch-all module. It just looks for any matching template. So /foo/bar would match in order: /foo/bar/index.tpl, /foo/bar.tpl, /foo/index.tpl, /foo.tpl, /index.tpl.

The null case just naturally searches for /index.tpl.

CGamesPlay
Member #2,559
July 2002
avatar

Matthew: what is your opinion on the CakePHP-style request handling like at the bottom of this post?

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

Matthew Leverton
Supreme Loser
January 1999
avatar

Are you referring to requiring that function names match the URL? I don't like it. But there's nothing preventing taking my generic request handler function and farming out requests to individual methods.

Vanneto
Member #8,643
May 2007

Still not sure what to do... I could let the News module handle the empty request and just display the page as the index. I could implement an Empty request module and when an empty request happens I fetch the news and everything thats needed on the front page and display it.

Anyway, while this thread is still open, could anyone help me with a regex? I need a regex for something like this:

<lang string="SOMETHING" args=($foo, $bar)/>

This would be translated into:

sprintf($language[SOMETHING], $foo, $bar);

I'm currently trying with a regex but it wont work no matter what I do. My regex skills are broken.

In capitalist America bank robs you.

 1   2   3   4 


Go to: