You are here: Re: a question about URL formating /category/13/ vs /category.php?id=13 « PHP Programming Language « IT news, forums, messages
Re: a question about URL formating /category/13/ vs /category.php?id=13

Posted by Kim Andrι Akerψ on 01/29/07 15:50

just_me wrote:

> Hello,
>
> I'd like to ask if anyone knows the format /category/13/ where
> probably 13 is the ID if it's actually a
> directory/file and a script automatically created it when someone
> updated his site or they just use
> a regex method to extract the number (which means 13 is virtual), in
> our case '13' and then try "select 'bla bla' from table where id='13'
> "
> which is the same as "$id = $_GET['id'];" with the second type of
> formating.
> Can I found this, if it is already scripted instead of writing it on
> my own?
> Any links? Is it hosted in any framework?

As Erwin pointed out, this is something handled by mod_rewrite in
Apache (I don't know if there's an equivalent in IIS, and if so, what
it is).
To make /category/13 point open the URL /category.php?id=13, you'd put
something like the following in a .htaccess file in the web root
directory:

RewriteEngine on
RewriteRule ^\/category\/([0-9])+ /category.php?id=$1 [L]

--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация