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