Robert Filter
Robert Filter

Reputation: 1721

With query string go here, without go there, .htaccess redirect

I have made a static image of a website and link the html files through a rewrite rule:

RewriteRule ^$ static/index.html [L]
RewriteRule ^stuff$ static/stuff.html [L]

etc. I know, this is not the most clever way but it works. Now the problem: I would like that

domain.com/?format=feed&type=rss

is handled again by the index.php of the cms that still lives in the root directory. My attempts like

RewriteCond %{REQUEST_FILENAME} !feed=

were not successful - the request is always only appended at the redirected static file.

How could I achieve that the feed request is indeed processed by the cms?

My background is that although elaborate caching mechanism exist, none of them is even comparably responsive as static files for shared hosting. Thanks in advance!

Edit: Closest as I come seems

RewriteCond %{QUERY_STRING} !^(.*&)?format=feed
RewriteRule ^(.*)$ static/%{REQUEST_URI}.html [L,QSA,R=301]

But this leads to a trailing slash too much when directed to the static version...

Upvotes: 0

Views: 67

Answers (1)

Olaf Dietsche
Olaf Dietsche

Reputation: 74048

You can just test for format=feed. No further context needed

RewriteCond %{QUERY_STRING} !format=feed

or you can do it the other way round and explicitly rewrite to index.php

RewriteCond %{QUERY_STRING} format=feed
RewriteRule ^$ /index.php [L]

Upvotes: 1

Related Questions