【问题标题】:URL redirect if contains a word如果包含单词,则 URL 重定向
【发布时间】:2016-03-23 08:15:03
【问题描述】:

如何通过 htaccess 重定向所有包含特定单词的 URL

例如:

http://videos.showtime.com.ph/its-showtime-hashtag-boys-macho-dance_03be98da6.html

应该被重定向到:

http://showtime.com.ph

具体的词应该是its-showtime。应重定向所有 its-showtime 所在的 URls。

我已经尝试了一些方法,但不起作用。

更新:现有 .htaccess 文件:

RewriteCond %{HTTP_HOST} ^([^.]+)\.showtime\.com\.ph$ [NC]
RewriteRule ^(.*)$ showtime\.com\.ph/$1 [L,R=301,NC]

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

已解决: https://webmasters.stackexchange.com/questions/88435/how-to-redirect-url-with-specific-characters/88440?noredirect=1#comment108357_88440

【问题讨论】:

    标签: php apache .htaccess mod-rewrite redirect


    【解决方案1】:

    您可以在 .htaccess 中使用它:

    RewriteEngine on
    RewriteRule its-showtime http://showtime.com.ph [NC,R=301,L]
    

    【讨论】:

    • 感谢您的帮助,但不幸的是这不起作用。我把你的代码放在我的 .htaccess 和 .conf 中我也试过这样:RewriteEngine on RewriteRule its-showtime showtime.\.com\.ph/$1 [NC,R=301,L]跨度>
    • 您的 .htaccess 中没有其他内容?
    • RewriteCond %{HTTP_HOST} ^([^.]+)\.showtime\.com\.ph$ [NC] RewriteRule ^(.*)$ showtime\.com\.ph /$1 [L,R=301,NC] RewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多