Pergunta

After migrating ta large static site to wordpress (as well as a reconstruction), I have a permalink structure that differs from the original directory structure, yet the new post slugs are the same as the original filenames. It's also worth mentioning that the permalink structure mimics the file extension of the old file path.

For example:

what was once (static directory)

www.example.com/old/path/file.htm

is now (wordpress permalink structure)

www.example.com/new/path/file.htm (note: permalink structure mimics the .htm extension)

My question: Is there a simple htaccess rewrite rule that can redirect visitors from /path/to/file/(file.htm) to /new/path/to/(file.htm), without having to create a redirect for each file?

Foi útil?

Solução

Using mod_alias is even easier:

Redirect 301 /old /new

But if you have rewrite rules in your htaccess file already, then you need to stick with using mod_rewrite:

RewriteRule ^old/(.*)$ /new/$1 [L,R=301]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top