Hey everyone, new poster here! I have a client that is migrating a bunch of sites to a single domain (consolidating brands into one single brand) and I'm helping with redirects.
We want to implement a "catch-all redirect" to ensure that every URL on the site is redirected (beyond the list of URLs that we know about, since Google sometimes has other legit or bogus URLs redirected).
But, we also want to exclude the /robots.txt and /sitemap.xml files from this "catch-all redirect" to ensure that Google (and other search engines) can render the /robots.txt file to see the link to the /sitemap.xml file, and then crawl those URLs in the /sitemap.xml file in order to see the redirect rules. We're having difficulty with this.
Here is the Catch-All Redirect the Client is Using: RewriteCond %{REQUEST_URI} .*\/
RewriteRule ^.*$ http://www.example.com/specific-url-here.htm [L,R=301]
Here are the URLs we want to exclude from the Catch-all Redirect: - http://www.example.com/robots.txt
- http://www.example.com/sitemap.xml
Here is the exclusion rule we tried, which didn't work: #Sitemap/Robots: exclude anything that includes /sitemap.xml, /robots.txt
RewriteCond %{REQUEST_URI} !^/(sitemap.xml|robots.txt) [NC]
Note: We also tried removing ".xml" and ".txt" from the exclusion rule code, but that didn't work either.
Here is a sample of the .htaccess file to show how it's set up: NOTE: I swapped out the client's domains and URL slugs/strings with "example" and "specific-url-here" text for privacy reasons. # Redirect rule to get sitemap.htm to map to example.com sitemap.htm
RedirectMatch 301 /sitemap.htm.* http://www.example.com/sitemap.htm
# Enable the rewrite engine
RewriteEngine On
#Sitemap/Robots: exclude anything that includes /sitemap.xml, /robots.txt
RewriteCond %{REQUEST_URI} !^/(sitemap.xml|robots.txt) [NC]
# Redirect index.html to domain root - check to see if extension might be .htm
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.htm\ HTTP
RewriteRule index\.html$ http://www.example.us/%1 [R=301,L]
RewriteCond %{REQUEST_FILENAME}.htm -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.htm [L]
RewriteCond %{REQUEST_URI} .*\/specific-url-here-1.htm
RewriteRule ^.*$ http://www.example.com/specific-url-here-1-new-site.htm [L,R=301]
RewriteCond %{REQUEST_URI} .*\/specific-url-here-2.htm
RewriteRule ^.*$ http://www.example.com/specific-url-here-2-new-site.htm [L,R=301]
RewriteCond %{REQUEST_URI} .*\/
RewriteRule ^.*$ http://www.example.com/specific-url-here-3-new-site.htm [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
<FilesMatch "\.pdf$">
header set x-robots-tag: "noindex"
</FilesMatch>
Can anyone help? [edited by: phranque at 12:04 am (utc) on Feb 21, 2015]
[edit reason] Please Use example.com [webmasterworld.com] [/edit]