views:

36

answers:

1

Hi,

I want that a url http://domain.com/sitemap.xml internally points to a file sitemap_book.xml in htdocs without any 301/302 redirects.

Please suggest a Rewrite Rule for the same.

I came up with

  RewriteCond %{REQUEST_FILENAME} "sitemap.xml"
  RewriteRule ^(.*)$ sitemap_book.xml [R]

but it doesn't work without [R]. Gives 400 bad request

When I use [P], I get 502 Proxy Error. I tried setting up mod_proxy with following code

<IfModule mod_proxy.c>
ProxyRequests On

<Proxy *>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Proxy>
</IfModule>

That gives 403 Forbidden.

+1  A: 

REQUEST_FILENAME is always an absolute filesystem path while REQUEST_URI is always an absolute URL path. So your example would rather work with RewriteCond %{REQUEST_URL} =/sitemap.xml (=: lexicographical comparison) or even directly in the RewriteRule pattern:

RewriteRule ^/sitemap\.xml$ sitemap_book.xml

Furthermore the R flag is always causing an external redirect rather than an internal. So just leave it away:

RewriteRule ^/sitemap\.xml$ sitemap_book.xml
Gumbo
This isn't working either. It says 400 Bad Request. Works when I add [R] to make it an external redirect. Any ideas why apache isn't picking up the internal redirect?
Sanjay