Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

332
Visualizações
How do I make clean URLs (no file extensions) and also redirect from.html to .shtml at the same time without changing all my html code?

I wanted to use file extensions within the question body to make it clear as possible but the system kept throwing code errors at me when I hadn't used anything like code.

I have numerous pages that comprise a section of my website. Let's, for example, call the main page:

http://www.articles.mysite.com/

With in that, let's say some of the html files are:

"10things"
"extras"
"t7n"
"i2""

Essentially, the file names tie into what they contain, but they don't all follow the same name pattern for whatever reason (some are just numbers, some are numbers and some are numbers and letters together, for instance).

What I want to do now is upgrade these files so I can use serverside includes (SSI's) as I do on other pages of my website. However, I'm running into a couple of issues.

  1. The URLs aren't clean (they have file extensions) and the same is true of links I've posted to social media, for instance. I'd like the resultant URL the user sees to not show these file extensions, partly for SEO and partly just to make it look less cluttered.

  2. When I've tried upgrading the files by just changing their names, the links on my end appeared to work, but when using one of the social media links, I kept getting 404 errors so I started from scratch and kept trying to resolve the issues on my own. Unfortunately this hasn't worked and I'm now back to square one, with the links currently working with standard files.

To reiterate, I'd like the following to occur:

  1. User clicks a link, whether directly on my site or on a social media site that takes me to a page on my own website.
  2. Even if the link is one of the old ones, the user is silently redirected to the new version of the page, with a clean URL that does not include any extension for better readability and SEO purposes.
  3. All this should ideally be able to happen without me needing to change the index files that store the links, only renaming the html file extensions.

The only two pieces of information that might be of help if I can figure out how to combine them are as follows:

  1. This introduction to redirects, which references mapping file types as part of redirect matching with the same path and filename:

Could this be modified, changing the extensions used, to map the requests to the new renamed files from the old extension?

  1. This previous question from Stack Exchange about rewriting and redirecting at the same time which talks about cleaning up extensions:

Could this be combined with the redirection in the previous question to make a clean and easy method of redirecting the user, cleaning up the extension and making it look as if nothing's changed with a file name being all that's required other than the above code?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can use this code to redirect your .html page to .shtml page without changing any line of code.


#redirect .html link to .shtml link 

RewriteEngine On
RewriteRule ^(.*)\.html$ $1.shtml [L]



over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda