Re: URL Rewriting

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

 



On Wednesday, June 22, 2011, Daniel Brown wrote:

>> RewriteEngine on RewriteRule ^theme([0-9]+).php$
>>  /index.php?theme=$1 [L]

>     That's neither nginx nor PHP, so it's not really relevant to the
> OP's questions.

I guess that the answer should be that you can rewrite outside of PHP
and then make use of the rewrites within your PHP application.
However, you can't AFAICT rewrite within PHP itself.

FWIW, I'm using mod-rewrite in one of my applications. In my .htaccess
file, I have:

------------8<-----------------------
RewriteEngine On
RewriteRule ^/$ master.php?url=index.html [L]
RewriteRule ^(.+\.html)$ master.php?url=$1 [QSA,L]
------------8<-----------------------

So that all .html files get rewritten to master.php with the
originally requested file on the querystring. In master.php, I then
have something like:

  $content = str_replace(".html", "", $_GET['url']) . ".php";
  require ('header.php');
  if (file_exists($content)){
    include ($content);
  }
  require ('footer.php');

This lets me have all the common content in required files with the
content that is unique to each page defined separately and without
needing to embed the top-level page structure in each page. It also
gives me 'search-engine-friendly' URIs.

HTH,

-- 
Geoff


-- 
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