【问题标题】:htaccess redirect if domain not contain keyword如果域不包含关键字,则 htaccess 重定向
【发布时间】:2014-11-13 14:48:33
【问题描述】:

如果域不包含某些关键字,我该如何重定向?

例子:

我的具有允许访问权限的域是

www.example.net/example/thisisallowed*

www.example.net/examplefolder/thisisallowedtwo

以及所有其他 URL,例如每个示例

www.example.net/example/notallowed

www.example.net/example/anotheruri

被禁止?

所以所有没有我的 URL 密钥的 URL 都应该被重定向到:

www.example.net/example/thisisallowed

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    您可以在 DOCUMENT_ROOT/.htaccess 文件中使用此代码:

    RewriteEngine On
    
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.net$ [NC]
    RewriteCond %{THE_REQUEST} !/thisisallowed [NC]
    RewriteRule ^ http://www.example.net/example/thisisallowed [L,NC,R=302]
    

    【讨论】:

    • 感谢您的回答。遗憾的是,这不起作用...:-/我收到此错误:错误:重定向错误该站点正在以一种他们永远不会完成的方式重定向请求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-08
    • 2018-07-31
    • 1970-01-01
    • 1970-01-01
    • 2011-03-14
    • 1970-01-01
    相关资源
    最近更新 更多