假设我有一些这样的网址:
http://mydomaindotcom/abc/123-link.html
http://mydomaindotcom/abc/page/page-link.html
现在,我想将以下所有网址重定向:http://mydomaindotcom/ otherstring /123-link.html至http://mydomaindotcom/ abc / 123-link。 HTML
或http://mydomaindotcom/ 另一个人 /page/page-link.html到http://mydomaindotcom/ abc /page/page-link.html
这意味着URL上的第一个段必须是[abc],否则,重定向到[abc] -beginning。
我该怎么做?
答案 0 :(得分:2)
试试这个:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/abc/ [NC]
RewriteRule ^[^/]+/(.*)$ /abc/$1 [R=301,L,NC,QSA]