php - 更改我所有的网站链接 : what is the best way?

标签 php .htaccess hyperlink

Possible Duplicate:
.htaccess rewrite to redirect root URL to subdirectory

我需要更改我网站中的所有链接(2455)。

当访问者来自 Google(使用旧链接)时,将会出现问题,因为页面将是 404 page not found

我想将旧链接重定向到新版本的页面。例如:

旧链接:

http://example.com/hotel/13234
http://example.com/hotel/132
http://example.com/hotel/323
http://example.com/page/about_us
http://example.com/page/contact

新链接:(在域名后添加“博客”)

http://example.com/blog/hotel/13234
http://example.com/blog/hotel/132
http://example.com/blog/page/about_us
http://example.com/blog/hotel/323

...
...
...

最好的方法是什么?

最佳答案

使用mod_rewrite :

RewriteEngine On
RewriteRule $ /blog [L,R=301]

这将为所有链接添加 blog 前缀并永久重定向它们。

关于php - 更改我所有的网站链接 : what is the best way?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14073832/

相关文章:

excel - 在 MAILTO : Hyperlink Formula 中创建新行

php - 使用php向表中插入数据

php - 通过 codeigniter 中的 Controller 传递给模型?

apache - 如何使用 .htaccess 创建重定向以正确的路径而不是页面访问

.htaccess - 重定向 http 到 https 和非 www 到 www

css - 如何在多行上扩展 css 文本动画?

Excel 超链接 - 跳转到单元格并滚动窗口

PHP PEAR 如何检查默认目录?

PHP 对象属性中有方括号

css - 网站布局损坏,可能是由于 htaccess