Pregunta

Quiero redirigir todas las solicitudes de index.html | php | php5 a http: //www.domain .co.uk / usando mod_rewrite y he copiado el código de un libro sobre optimización de motores de búsqueda con PHP textualmente, luego lo agregué en la opción php5, pero no funciona. Este es mi archivo .htaccess completo:

RewriteEngine On

#translate any .html ending into .php5
RewriteRule ^(.*)\.html$ /$1\.php5

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)\HTTP
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]

#change / for ?
RewriteRule ^(.*)\.html/(.*)$ /$1\.html?$2

#strip .html from search res page
RewriteRule ^(.*)search/(.*)$ /$1search_results\.html/search=$2

#translate product details link from search res page
RewriteRule ^products/(.*)/(.*)/(.*)$ /product_details.php5?category=$1&title=$2&id=$3 [L]

#Translate products/psorisis/chamomile-skin-cream-P[x] to productview.php5?id=1
RewriteRule ^products/.*-P([0-9]+) /productview.php5?id=$1 [L]

No sé qué hay de malo en eso, y el resto funciona bien y dandy. ¿Alguien tiene alguna idea?

¿Fue útil?

Solución

Creo que es porque su RerwriteCond termina con \ HTTP .

Cámbielo a:

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]

Si desea hacer coincidir el HTTP de THE_REQUEST, coloque un espacio allí

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)\ HTTP
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top