Re: mod_rewrite
| From: | Rainer Müller | Date: | Sat, 23 Apr 2005 20:08:33 +0000 |
| Subject: | Re: mod_rewrite | ||
| References: | 1 2 3 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2710@lists.php.net to get a copy of this message | ||
David Triebe wrote:
> Hi Pete,
> I've not that much experience with mod_rewrite, but I think, that the
> translation of GET-parameters won't work.
It works of course.
You could write something like
> this into the .htaccess file:
>
> RewriteEngine On
> RewriteRule \.html$ index.php
>
> Which would send every request that goes on a .html-page (no matter if
> existing or not) to the index.php. There you're able to parse the URI
> from $_SERVER['REQUEST_URI'] which should still be the requested one
> without any translations.
I use the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/themes.*
RewriteRule ^(.*)$ index.php?path=$1 [L,QSA]
It rewrites if there is no directory and no file with this name and
explicitly excludes request in the themes/ directory which includes my
images (no need for them to be passed through php). [L,QSA] serves that
this is the only rewrite which is done and QSA stands for query string
append. I could even request foo/?blah=bar and it would become
index.php?path=foo/&blah=bar.
HTH, Rainer