且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重定向到不同的域和URL结构

更新时间:2023-09-12 09:12:04

通过以下方式启用 mod_rewrite .htaccess httpd.conf (如果尚未启用),然后将此代码放在 DOCUMENT_ROOT / .htaccess 文件中:

Enable mod_rewrite and .htaccess through httpd.conf (if not already enabled) and then put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{SERVER_PORT}s ^(443(s)|\d+s)$
RewriteRule ^([0-9]{4}/[0-9]{2}/[0-9]{2}/[^/]+/?)$ http%2://sample.com/sub/sub2/$1 [L,QSA,R=301]