1

实际上我用 PHP 做这个,但我想在 Apache 级别上做这个(.htaccess)

我想对以下开头的网址进行 301 重定向:noticias|analises|meteorologia|artigos|videos而不是以斜杠或 .html 结尾

我想重定向到带有斜杠的页面。

在这些情况下重定向:

/noticias  --> /noticias/
/noticias/soja --> /noticias/soja
/noticias/soja/pag-2 --> /noticias/soja/pag-2/

但在这种情况下不是:

/noticias/soja/1105-soja-opera-em-alta.html

拜托,有人可以帮助我吗?

4

1 回答 1

0

只需将其放入目录的.htaccess文件中:

# noticias/
RewriteEngine on
RewriteRule ^index.php$ http://www.example.com/noticias/ [r=301,nc]

或者对于第二个目录:

# noticias/soja/
RewriteEngine on
RewriteRule ^index.php$ http://www.example.com/noticias/soja/ [r=301,nc]

对于第三个目录:

# noticias/soja/pag-2/
RewriteEngine on
RewriteRule ^index.php$ http://www.example.com/noticias/soja/pag-2/ [r=301,nc]
于 2013-01-16T21:42:13.600 回答