I am using mod_rewrite to write domain.com/index.php?=string to domain.com/string. I need to have the website display the index.php?=sitemap when a robot goes to sitemap.html for SEO purposes. I have tried lots of variations and have gotten /sitemap to show /sitemap.html using the code:
RewriteRule ^sitemap/?$ http://www.domain.com/sitemap.html [R]
The rewrite understandably does not fix the issue however because it actually is looking for sitemap.html not index.php?p=sitemap.
The rules currently in place are:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?p=$1& [L,NC]
Any help is greatly appreciated.
Just add this inbetween both of your rules:
RewriteRule ^sitemap\.html$ index\.php?p=sitemap [L]
So it all looks like:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
RewriteRule ^sitemap\.html$ index\.php?p=sitemap [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?p=$1& [L,NC]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.