应该是一个简单的 301 重定向
Should be a simple 301 redirect
我认为应该简单的东西就是行不通。
我换了域名
旧URL示例:
digital.photorecommendations.com/recs/2015/01/big-zoom-field-review/
新URL示例:
照片拍摄tv/2015/01/big-zoom-field-review/
真的只是切换域并从 URL
中删除 recs 文件夹
使用http://htaccess.madewithlove.be/进行测试并输出正确的URL
Options +FollowSymlinks
RewriteEngine on
RewriteBase /recs
RewriteCond %{HTTP_HOST} !^www\.digital.photorecommendations\.com$ [NC]
RewriteRule ^recs(.*) http://photorec.tv/ [L,R=301]
当我将它放在 htaccess 文件中时,我在除主页之外的所有页面上都收到 404 错误。 htaccess 文件位于 /recs 文件夹中。我也在 digital.photorecommendations.com 的根目录下尝试过,但完全没有结果。
有什么建议吗?
谢谢!
您在 RewriteCond
中错误地使用了否定,正则表达式也需要修复。在 /recs/.htaccess
:
中使用此规则
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?digital\.photorecommendations\.com$ [NC]
RewriteRule ^(index\.php)?$ http://photorec.tv/ [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?digital\.photorecommendations\.com$ [NC]
RewriteRule ^(.+)$ http://photorec.tv/recs/ [L,R=301,NC,NE]
我认为应该简单的东西就是行不通。
我换了域名
旧URL示例: digital.photorecommendations.com/recs/2015/01/big-zoom-field-review/
新URL示例: 照片拍摄tv/2015/01/big-zoom-field-review/
真的只是切换域并从 URL
中删除 recs 文件夹使用http://htaccess.madewithlove.be/进行测试并输出正确的URL
Options +FollowSymlinks
RewriteEngine on
RewriteBase /recs
RewriteCond %{HTTP_HOST} !^www\.digital.photorecommendations\.com$ [NC]
RewriteRule ^recs(.*) http://photorec.tv/ [L,R=301]
当我将它放在 htaccess 文件中时,我在除主页之外的所有页面上都收到 404 错误。 htaccess 文件位于 /recs 文件夹中。我也在 digital.photorecommendations.com 的根目录下尝试过,但完全没有结果。
有什么建议吗?
谢谢!
您在 RewriteCond
中错误地使用了否定,正则表达式也需要修复。在 /recs/.htaccess
:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?digital\.photorecommendations\.com$ [NC]
RewriteRule ^(index\.php)?$ http://photorec.tv/ [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?digital\.photorecommendations\.com$ [NC]
RewriteRule ^(.+)$ http://photorec.tv/recs/ [L,R=301,NC,NE]