Re: Search like php.net's URL thingy

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

 



Ryan S wrote:
Hey!

Thanks for replying.

Digging a bit more i found
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([a-z][0-9][A-Z][aA0-zZ0])$ jj.php?show=$1
</IfModule>

But it does not work :( do you see any fault with the above?

this is an apache issue, not a php issue, so you'll probably have better luck on an apache mailing list.

however i will tell you that apache handles URLs in .htaccess differently from in the normal httpd.conf files. in the .htaccess file, the URL presented to RewriteRule does NOT have a leading /. in the conf file, it will. so your rule might work if you do this:

RewriteRule ^/([a-z][0-9][A-Z][aA0-zZ0])$ jj.php?show=$1

i'm guessing that you are using .htaccess though, in which case the problem becomes the rule itself. your regex is not going to do what you think. it's saying "lower case letter followed by number followed by uppercase letter followed by i don't know what the heck that is." try:

RewriteRule ^(\w+)$ jj.php?show=$1 [L]

\w is equivalent to [A-Za-z0-9_] note that this is NOT the same as [A-Z][a-z][0-9]

you almost always want [L] in a situation like this to prevent later rules from messing with your rewritten string.

also i will tell you that if you ever plan to launch this feature on a site that gets significant traffic, turning off .htaccess file checking is a HUGE performance win. unfortunately you will have to restart apache every time you want to modify your rewrite rules, but them's the breaks.

-jsd-


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