Pergunta

Eu tenho um site com alguns arquivos HTML. Um deles é contact.html. Este é o meu .htaccess, e estou tendo problemas em que posso abordar a página com site.com/contact, mas não site.com/contact/. (Nota final Slash.) Qual é a correção?

RewriteEngine On

# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_fileNAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_fileNAME} !-f
# then add .html to get the actual filename
rewriterule (.*) /$1.html [L]
Foi útil?

Solução

Ao invés de:

rewriterule (.*) /$1.html [L]

Tentar:

RewriteRule ^([^/]*)/?$ /$1.html [L]

Outras dicas

RewriteRule ^([^/]*)/?$ $1.php [L]

No meu caso, vou remover o Slash antes de US $ 1 e funciona! Agradeço a aprender muito com o seu comentário.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top