Forum Moderators: phranque

Message Too Old, No Replies

.htaccess help needed

rewrite rule

         

devil_dog

3:46 am on Oct 6, 2008 (gmt 0)

10+ Year Member



Hi. i have the following

RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*s=.*
RewriteCond %{HTTP_USER_AGENT} !something
RewriteCond %{QUERY_STRING} !.*attachment_id=.*
RewriteCond %{HTTP_COOKIE} !^.*(comment_author_¦wordpress¦wp-postpass_).*$
RewriteCond %{DOCUMENT_ROOT}/cache/somefolder/$1.html -f
RewriteRule ^(.*) /cache/somefolder/$1.html [L]

Basically what it does is rewrite

www.example.com/abab/foo

to

/cache/somefolder/abab/foo.html only if the file exists... otherwise follow other directives.

What i would like it to do additionally is rewrite :

www.example.com/abab/foo/feed

to

/cache/somefolder/abab/foo.xml

any clues here? I am absolutely hopeless in regexp and rewrite rules.
Any help will be highly appreciated.

g1smd

8:33 am on Oct 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Which folder is that .htaccess rule located in? That is crucial to how to formulate the rules you will need.

In all of your RewriteCond lines, if there is a .* that is immediately adjacent to a start or end anchor, you can safely delete the .* and delete the start or end anchor.

In all of your RewriteCond lines, if there is a .* at the very beginning or at the very end of the condition, then the .* part can be deleted.

In the RewriteRule, the .* matches "everything" so it will need to be altered to match a specific pattern.

You'll then need another Rule to match some other different specific pattern.

The problem you face isn't all that much different to this post from just yesterday: [webmasterworld.com...]