Forum Moderators: phranque
/asp -> /index.php?c=asp&s=&p=
/php/security -> /index.php?c=php&s=security&p=
/seo/google/3 -> /index.php?c=seo&s=google&p=3
I just want the basic rule, no flags etc.
My unsuccessful attempt:
RewriteRule ^([^/]*)/*([^/]*)/*([^/]*)* index.php?c=$1&s=$2&p=$3 [NC,L]
Thanks,
krt
Welcome to WebmasterWorld!
Addressing this thread's title, we're here to discuss Apache, and not to write code on demand -- Please review our forum charter [webmasterworld.com].
That said, there are a few questions that need to be answered in the interest of server efficiency. The main one being whether these are the only three requested URL forms that you want to rewrite. If so, then using three separate, specific rules would be the best way to go.
If you have other forms of URLs that you also need to rewrite, then those have to be taken into account. The goal is to balance the processing time of specific rules against that of a generic ambiguous rule. Bearing in mind that an ambiguous rule takes longer to process -- sometimes much longer, and that every single request to your server will be processed through it, it's often better to use specific rules -- up to the point where you have several dozens of rules.
Specific:
RewriteRule ^asp/?$ /index.php?c=asp&s=&p= [L]
RewriteRule ^php/security/?$ /index.php?c=php&s=security&p= [L]
RewriteRule ^seo/google/3/?$ /index.php?c=seo&s=google&p=3 [L]
RewriteRule (asp)/?¦(php)/(security)/?¦(seo)/(google)/(3)/?$ /index.php?c=$1&s=$2&p=$3 [L]
RewriteCond %{REQUEST_URI} !^index\.php$
RewriteRule ^([^/]+)(/([^/]+)(/([^/]+))?)?/?$ /index.php?c=$1&s=$3&p=$5 [L]
Notes:
Jim