Estoy usando mod_rewrite para escribir domain.com/index.php? = cadena a domain.com/string. Necesito que el sitio web muestre index.php? = Sitemap cuando un robot vaya a sitemap.html para fines de SEO. He probado muchas variaciones y he obtenido / sitemap para mostrar /sitemap.html usando el código:
RewriteRule ^sitemap/?$ http://www.domain.com/sitemap.html [R]
Sin embargo, la reescritura no soluciona el problema porque en realidad está buscando sitemap.html no index.php? P = sitemap.
Las reglas actualmente vigentes son:
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]
Cualquier ayuda es muy apreciada.
Respuestas
0 para la respuesta № 1Solo agrega esto entre ambas reglas:
RewriteRule ^sitemap.html$ index.php?p=sitemap [L]
Así que todo se ve como:
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]