You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Justin French <ju...@indent.com.au> on 2003/07/27 04:47:53 UTC

[users@httpd] rewrite and +MultiViews on the root file (index.php)

Hi all, I'm trying to use the rewrite rule and/or "Options +MultiViews"
to implement "user freindly URLs" under an apache/php/mysql setup.

So, http://example.com/review/book/145 translates to
http://example.com/review.php?category=book&id=145.

I've got this working fine, but now I'm hoping to take it one step
further.  I'd like everything to run through one "fusebox" script
(index.php) transparently.  In other words, I can get this to work:

http://example.com/index/about/team >
http://example.com/index.php?section=home&page=team,

but can't get index.php to work transparently:

http://example.com/about/team >
http://example.com/index.php?section=home&page=team


Is this possible?


At the moment I'm just using "Options +MultiViews" in my .htaccess
file,a nd am letting PHP parse the URL to assign the variables, so I'd
prefer to keep things this way.


TIA

Justin French


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] rewrite and +MultiViews on the root file (index.php)

Posted by Joshua Slive <jo...@slive.ca>.
On Sun, 27 Jul 2003, Justin French wrote:
> I've got this working fine, but now I'm hoping to take it one step
> further.  I'd like everything to run through one "fusebox" script
> (index.php) transparently.  In other words, I can get this to work:
>
> http://example.com/index/about/team >
> http://example.com/index.php?section=home&page=team,
>
> but can't get index.php to work transparently:
>
> http://example.com/about/team >
> http://example.com/index.php?section=home&page=team
>
>
> Is this possible?

One easy way to do this is to simply point
ErrorDocument 404 /index.php
and look in the REDIRECT_* variables.
But this has some negative consequences (possible extra filesystem
lookups, etc).

The main complication in this is that you probably have one requirement
you haven't mentioned: you proabably want to serve images and other static
files from the server as well.  Then the question becomes: how can you
distinguish between requests that should go to the script, and requests
that should go to the filesystem.  Once you answer that, the answer should
be easy.

As an example, the following should direct everything to the script,
except requests that have a last component ending with an extension (eg.
/path/to/file.gif).

RewriteEngine On
RewriteCond %{REQUEST_URI} !.*/[^/]*\.[^/]*$
RewriteRule (.*) /index.php/$1

If you really meant that you want EVERYTHING to go to the script, then the
asnwer is really easy:

Alias / /full/unix/path/to/index.php

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org