V
V
Vertex2010-10-05 02:49:21
Apache HTTP Server
Vertex, 2010-10-05 02:49:21

RewriteRule, optimization?

There is a maximum long request:
www.site.com/admin/catalog/computers/page3/search/ [base64_encode_serialized_array]/filter_by_photo/sorted_by_id/
Request modifications can be different:
www.site.com/admin/catalog/computers/page3/filter_ ...
www.site.com/admin/catalog/computers/page3/sorted_...
etc.
All these URLs are processed by me now with one rule:
RewriteBase /
RewriteRule ^/?admin/catalog/([a-zA-Z]+)/(page([0-9]+)/?)?(search/([ a-zA-Z0-9]+)/?)?(filter_by_([a-zA-Z]+)/?)?(sorted_by_([a-zA-Z_]+)/?)?/?$ . /index.php?base=Catalog&dbname=$1&p=$3&search=$5&filter_by=$7&sort_by=$9 [L]
But now I feel that it is possible to optimize it, and I would like to take out the processing of spare parts separately, but I can’t find how to do it correctly, i.e. something like this:
RewriteBase /
RewriteRule ^/?admin/catalog/([a-zA-Z]+)/?$ ./index.php?base=Catalog&dbname=$1 [C]
RewriteRule ^/?page([ 0-9]+)/? &p=$1 [C]
RewriteRule ^/?search/([a-zA-Z0-9]+)/? &search=$1 [C]
RewriteRule ^/?filter_by_([a-zA-Z0-9]+)/? &filter_by=$1 [C]
RewriteRule ^/?sorted_by_([a-zA-Z0-9]+)/?
& sort_by =$1 [L] according to the algorithm, something like a search for a suitable beginning should turn out, and then we hang additions on it. Is it possible? And if so, how?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Ogra, 2010-10-05
@Ogra

It might be worth taking out the logic for processing "spare parts" from Apache and giving it to a PHP script. Again, it will be easier in which case to go to another server.

M
mihavxc, 2010-10-05
@mihavxc

I just have everything broken into parts by the first input parameter in the URL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question