[wp-hackers] .htaccess cleanup

Jeff Minard jeff at jrm.cc
Sun May 22 18:19:08 GMT 2005


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jeff.vcf
Type: text/x-vcard
Size: 156 bytes
Desc: not available
Url : http://comox.textdrive.com/pipermail/wp-hackers/attachments/20050522/e719b3c3/jeff.vcf


More information about the wp-hackers mailing list