php - .htaccess 301 路径 URL 重组?
问题描述
我阅读了很多关于完整域的 301 重定向的内容,但无法了解如何将现有路径准确更改为新路径。
这是一个例子:
site.com/cars到site.com/motobikes
和:
site.com/cars/tires到sote.com/motobikes/(变量,例如柏林、巴黎)/tires
我怎样才能完成这项任务?
解决方案
您可以在 PHP 中以这种方式进行重定向
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/$var");
exit();
或者您可以使用 .htaccess 文件Redirect 301 /cars http://example.com/motobikes
推荐阅读
- aggregate - Kendo UI TreeList - 子聚合隐藏
- arrays - 将新值推送到特定位置的现有数组中 React Hooks
- python - 传递给另一个类的 self 变量的正确文档字符串文档是什么
- woocommerce - Woocommerce:在订单页面详细信息中获取并打印客户语言
- spring - JdbcBatchItemWriterBuilder 与 org.springframework.jdbc.core.jdbcTemplate.batchUpdate
- r - Choosing the right parameterization for latent profile analyses using the TidyLPA package
- elasticsearch - 与 Elastic Search 1.4.2 相比,Elastic Search 7.9 索引花费的时间太多
- entity-framework - 如何在 .NETCore 3.1 和 Blazor 中创建 DbContextFactory
- google-pay - CRYPTOGRAM_3DS - 为什么它不是唯一的选择?
- javascript - 是否可以在Javascript(Ionic,Angular)中将blob文件转换为base64Data?