How To Redirect with modified URL using .htacess

萝らか妹 提交于 2019-12-11 14:47:36

问题


I want to move my website to a new domain. But, facing a problem with Permalink structure. Example,

Old Structure: oldsite.com/salman-khan-biography/
New Structure: newsite.com/salman-khan-movies/

Actually, just single word will be changed from the end of permalinks. I tried below codes, but it's showing 404 not found on the new domain.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC]
RewriteRule ^(.*)$ http://newsite.com/$1 [L,R=301,NC]

回答1:


Try with below in your old website htaccess.

RewriteEngine On
RewriteCond %{REQUEST_URI} (.+)\-biography/?$
RewriteRule ^ http://newsite.com/%1-movies/ [R=301]


来源:https://stackoverflow.com/questions/50724548/how-to-redirect-with-modified-url-using-htacess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!