开发者

htaccess 301 redirects - need help

开发者 https://www.devze.com 2023-04-05 01:19 出处:网络
I\'m stuck. I don\'t know much about htaccess and I\'m just winging it. Can someone look at the code and tell me what\'s wrong with it. I simply want to redirect an old site to a开发者_如何学Go new si

I'm stuck. I don't know much about htaccess and I'm just winging it. Can someone look at the code and tell me what's wrong with it. I simply want to redirect an old site to a开发者_如何学Go new site and the only changes are the domain, a variable that will match between old/new pages and an added word to the permalink structure.

Here's one of the variations I've tried so far:

Options +FolowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*domain.com/matchingword1-(.*)-matchingword2-matchingword3/ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/matchingword1-$1-matchingword2-differentword-matchingword3/ [R=301,L]

The section (.*) will be the exact same as $1 on the new domain but the permalink is a little different. The part of the permalink that is (.*) will be anything from multiple words and numbers.

For example: matchingword1-this-page-is-1st-matchingword2-matchingword3/ redirects to newdomain.com/matchingword1-this-page-is-1st-matchingword2-differentword-matchingword3


Options +FolowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^.*domain.com/matchingword1-(.*)-matchingword2-matchingword3/ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com%{REQUEST_URI} [R=301,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号