【发布时间】:2021-09-17 11:19:01
【问题描述】:
我们的网络服务器上有许多博客文章,并且文件完全存在。例如:https://domain/blog/123.php。我们将所有文件导入数据库,前端只是从表中检索内容(标题、内容等)。
我使用动态页面来显示所有文章内容。但是对于 url ,它会像这样生成:
https://domain/blog/detail.php?q=123.php
https://domain/blog/detail.php?q=456.php
会影响seo排名,如何保持和WordPress一样的url呢?
https://domain/blog/123.php
https://domain/blog/456.php
https://domain/blog/789.php
我正在使用 apache,所以 .htaccess 可用。我正在尝试重写网址。
RewriteRule ^blog/123.php$ /blog/detail.php?q=123.php [L]
但这不符合我们的要求。我不想显示任何像/blog/detail.php?q=123.php 这样的网址。我只想保留 slug url。
【问题讨论】:
标签: url url-rewriting