.htaccess redirect all pages to new domain

前端 未结 18 2504
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 14:47

Which redirect rule would I use to redirect all pages under olddomain.example to be redirected to newdomain.example?

The site has a totally

18条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 15:14

    I've used for my Wordpress blog this as .htaccess. It converts http://www.blah.example/asad, http://blah.example/asad, http://www.blah.example2/asad etc, to http://blah.example/asad Thanks to all other answers I figured this out.

    
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{HTTP_HOST} !^YOURDOMAIN\.example$ [NC]
    RewriteRule ^/(.*)$ https://YOURDOMAIN.example/$1 [R=301,L]
    
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    
    

提交回复
热议问题