Re: URL Rewriting

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

 



Silvio Siefke <lists@xxxxxxxxxxxxxxxx> wrote:
> On Wed, 22 Jun 2011 17:50:49 -0400 Daniel P. Brown wrote:
> > > 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 ?
> 
> I have me write a blog, but my blog has link like blogdetail.html?id=1 or =2
> through 16 at moment. And for google and other Search  Engines not good the
> links, better where i can rewrite to a fix link, and when someone use the
> link, php write to correct url. 

Common SEO mythology is that you need pretty human-understandable
links. (In point of fact, the search engines care not in the least.)
However, human-understandable URLs are a benefit to users when they want
to understand what they're linking to or clicking on.

A human-understandable link is more like:

    http://www.example.com/blog/2013-05-a-day-in-the-life-of-my-dog

not:

    http://www.example.com/blog/2

as that really does not provide any more information than:

    http://www.example.com/blog.php?id=2

Otherwise, Daniel's solution below should do the trick.

> Sorry my english not perfect on earth. 
> 
>  
> >     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
> > 







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