[wp-hackers] .htaccess cleanup
Jonathan Leighton
turnip at turnipspatch.com
Sun May 22 19:23:13 GMT 2005
Jeff Minard wrote:
> Denis de Bernardy wrote:
>
>> RewriteRule ^(.+)(/[0-9]+)?/?$ /index.php?pagename=$1&page=$2 [QSA,L]
>
>
> Wouldn't that rule catch just about damn near everything?
>
> One of the clean ups I *do* find very useful is the combination of
> "page" htaccess definitions. Much the same lines of what you are
> thinking, but more specific.
>
> Example, instead of 5 lines for each page, have:
>
> RewriteRule ^(page1|page2|page3)/trackback/?$
> /index.php?pagename=$1&tb=1 [QSA,L]
> RewriteRule ^(page1|page2|page3)/feed/(feed|rdf|rss|rss2|atom)/?$
> /index.php?pagename=$1&feed=$2 [QSA,L]
> RewriteRule ^(page1|page2|page3)/(feed|rdf|rss|rss2|atom)/?$
> /index.php?pagename=$1&feed=$2 [QSA,L]
> RewriteRule ^(page1|page2|page3)/page/?([0-9]{1,})/?$
> /index.php?pagename=$1&paged=$2 [QSA,L]
> RewriteRule ^(page1|page2|page3)/?([0-9]+)?/?$
> /index.php?pagename=$1&page=$2 [QSA,L]
>
> Add "|pagename" as nessecary. This way you aren't catching things like
> "/robots.txt" with that last rule.
>
> Jeff
Or you could combine the two...
RewriteRule ^(.+)/trackback/?$ /index.php?pagename=$1&tb=1 [QSA,L]
RewriteRule ^(.+)/feed/(feed|rdf|rss|rss2|atom)/?$
/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(.+)/(feed|rdf|rss|rss2|atom)/?$
/index.php?pagename=$1&feed=$2 [QSA,L]
RewriteRule ^(.+)/page/?([0-9]{1,})/?$
/index.php?pagename=$1&paged=$2[QSA,L]
RewriteRule ^(page1|page2|page3)/?([0-9]+)?/?$
/index.php?pagename=$1&page=$2 [QSA,L]
Granted it's not *as* specific... but probably faster?
--
Jonathan Leighton aka. Turnip
http://turnipspatch.com/ | http://digital-proof.org/
More information about the wp-hackers
mailing list