Re: How to work with virtual (seo) URLs?
| From: | Richard Lynch | Date: | Mon, 20 Nov 2006 22:33:54 +0000 |
| Subject: | Re: How to work with virtual (seo) URLs? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244903@lists.php.net to get a copy of this message | ||
Forget the mod_rewrite madness and just do like this:
.htaccess file (or httpd.conf equivalent)
<Files section>
ForceType application/x-httpd-php
</Files>
Then inside section file, you can do:
$pathinfo = $_SERVER['PATH_INFO'];
//You now have /subsection/subsection/subsubsection in $pathinfo
//Do whatever you want with it.
On Sat, November 18, 2006 5:05 pm, Erik Gyepes wrote:
> Hi folks,
> my another question is how to work with URLs like below in PHP:
>
> http://www.example.com/section/
> http://www.example.com/section/subsection/
> http://www.example.com/section/subsection/subsubsection/
> http://www.example.com/section/subsection/subsubsection/ ....
>
> These URLs works very well with this mod_rewrite rules:
>
> ----
> RewriteEngine On
>
> #check if file or directory real exists:
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
>
> #do the rule only if the address has no extension:
> RewriteCond %{REQUEST_URI} !\.[[:alnum:]]+$
> #replace /whatever to /whatever/, not apply to whatever/!
> RewriteRule ^(.+[^/])$ /$1/ [R]
>
> #do the rule only if the address ends with trailing slash:
> RewriteCond %{REQUEST_URI} ^.*/$
> #if the rule ends with trailing slash then redirect to index.php..
> RewriteRule ^(.*)/$ /index.php?p=$1 [L]
> ----
>
> So Apache stage is solved, but how about the PHP stage?
> The problem is that there can be many of subsections and how I can
> know
> that for example /animals/ is a subsection of /photogallery/ and not
> /profile/ ???
>
> [url]http://www.example.com/photogallery/animals/[/url] - GOOD
> [url]http://www.example.com/profile/animals/[/url] - BAD
>
> How do you solve these things?
>
> One idea which I had is to store sections in array an then compare
> them
> with the section's name in URL, but I can't get it work for more
> nested
> URL's.
>
> Any ideas or web resources are appreciated!
> Cheers.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?