php - htaccess conflict between web route and public directory

326

I have a Magento project with a third-party module which creates a HTML sitemap at the /sitemap route. Meanwhile, we have a sitemap directory which contains a bunch of publically accessible XML sitemaps (published to Google etc). With the sitemap directory in place, the /sitemap route causes a redirect loop.

I'm looking for a htaccess rewrite rule which will allow me to serve the /sitemap URL through the standard index.php routing mechanism in Magento but allow sitemap/*.xml to be served as a file.

This is my attempt, which I was hoping would check if the URI contains /sitemap AND isn't a file, then rewrite the current request to the full URL of the HTML sitemap module, but it doesn't appear to have any effect.

RewriteCond %{REQUEST_URI} ^sitemap
RewriteCond %{REQUEST_URI} !-f
RewriteRule %{REQUEST_URI} sitemap/index/index #The full URL of the HTML sitemap page.
474

Answer

Solution:

Change :

RewriteCond %{REQUEST_URI} !-f

to

 RewriteCond %{REQUEST_FILENAME} !-f

People are also looking for solutions to the problem: How to call a function from a php file?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.