Re: URL Rewriting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 22, 2011 at 17:22, Silvio Siefke <lists@xxxxxxxxxxxxxxxx> wrote:
> Hello,
>
> is there a chance with php to use rewriting?
>
> Like Example:
>
> mysite.com/theme.php?id=1 to theme.php theme2.php etc.
>
> I have ask on the nginx list, but there they say i should use the power
> language php.
>
> When i search in google for Examples or Tutorials i only found mod_rewriting.
>
>
> Has someone a Link with Tutorials or other Information?

    Not entirely sure what you're asking here, or how you (or the
nginx folks) expect it to relate to PHP.  Do you mean that you want to
use PHP to have theme2.php act as if it was called as theme.php?id=2 ?

    If so, it's not redirect or rewrite, and it's extremely hacky, but
this is the only real way PHP could achieve the desired result:

<?php
// dynamictheme.php

if (preg_match('/.*([0-9]+)\.php/Ui',$_SERVER['PHP_SELF'],$match)) {
  $_GET['id'] = $match[1];
  include dirname(__FILE__).'/theme.php';
}

?>

    Then just symlink dynamictheme.php to your various themes like so:

    ln -s dynamictheme.php theme2.php
    ln -s dynamictheme.php theme301.php
    ln -s dynamictheme.php theme18447.php

-- 
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux