【发布时间】:2023-03-06 02:06:02
【问题描述】:
我的网站出现了一些错误,需要为我的网址进行 301 重定向,如下所示:
https://firstnamelastname.example.com/the-wall 转到 https://example.com/new-wall/firstnamelastname,其中 firstnamelastname 是任何名称。
【问题讨论】:
我的网站出现了一些错误,需要为我的网址进行 301 重定向,如下所示:
https://firstnamelastname.example.com/the-wall 转到 https://example.com/new-wall/firstnamelastname,其中 firstnamelastname 是任何名称。
【问题讨论】:
您可以在 DOCUMENT_ROOT/.htaccess 文件中使用此代码:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.(example\.com)$ [NC]
RewriteRule ^the-wall/?$ http://%2/new-wall/%1 [L,NC,R=301]
【讨论】: