<ifModule mod_rewrite.c>
ErrorDocument 404 /notfound.html
RewriteEngine On
Options +FollowSymLinks -Indexes -MultiViews
RewriteBase /
RewriteRule ^(gateway)($|/) - [L]
RewriteRule ^(inc)($|/) - [L]
# make sure it"s not a directory or a file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# match out the request URI without the trailing slash
RewriteCond %{REQUEST_URI} ^/([^/]+?)/?$
# and see if it exists
RewriteCond %{DOCUMENT_ROOT}/%1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
RewriteCond %{REQUEST_METHOD} !POST [NC]
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /(.+?).php
RewriteRule ^(.+?).php$ /$1 [L,R=301]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+index.php?id=([a-z0-9]+)&num=([a-z0-9]+) [NC]
RewriteRule ^ %1/%2/ [R=301,L,NC]
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]
</ifModule>
Hola chicos, Tengo problemas con htaccess. Todavía advierte por navegador acerca de Esta página web tiene un bucle de redireccionamiento Encuentro más solución pero no puedo solucionarlo :( Traté de reescribir / redirigir * .php a la muestra de directorio index.php a / index Y quiero reescribir url index.php? Id = read & num = 11233445667 to / read / 11233445667
Funcionó. Pero aún así "Esta página web tiene un bucle de redireccionamiento" :(
Por favor, ayúdame a arreglar htaccess arriba. Estoy muy gracias!
Respuestas
0 para la respuesta № 1Necesita colocar la última regla:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s/+index.php?id=([a-z0-9]+)&num=([a-z0-9]+) [NC]
RewriteRule ^ %1/%2/ [R=301,L,NC]
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]
cerca de la cima (abajo RewriteRule ^(inc)($|/) - [L]
)
para que no interfiera con las reglas de extensión php más generales. Probablemente también debería agregar condiciones a la reescritura interna:
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]
a:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)/?$ /index.php?id=$1&num=$2 [L,NC]