【问题标题】:.htaccess Redirect all subpages except one.htaccess 重定向除一个之外的所有子页面
【发布时间】:2018-03-15 00:30:59
【问题描述】:

我使用 .htaccess 将 Joomla 主页重定向到不同的域:

RewriteRule !^(media|administrator) http://newdomain.pl%{REQUEST_URI} [L,R=301]

有效。

我需要一个从重定向中排除的 URL,以便从时事通讯组件中收集统计信息。 所以我尝试了这个:

RewriteCond %{REQUEST_URI} !index.php?option=com_mycomponent&ctrl=stats
RewriteRule !^(media|administrator) http://newdomain.pl%{REQUEST_URI} [L,R=301]

但它不起作用,尽管我多次清除浏览器缓存。有什么想法吗?

【问题讨论】:

    标签: .htaccess joomla


    【解决方案1】:

    如果您想匹配请求的所有部分,请使用THE_RQUEST srever-varibale 而不是REQUEST_URI,因此请更改此:

    RewriteCond %{REQUEST_URI} !index.php?option=com_mycomponent&ctrl=stats
    

    有了这个:

    RewriteCond %{THE_REQUEST} !index\.php\?option=com_mycomponent&ctrl=stats
    

    【讨论】:

    • 没有必要转义 =_& 因为这些不是正则表达式特殊字符。
    猜你喜欢
    • 2014-09-11
    • 1970-01-01
    • 2011-09-13
    • 2016-11-30
    • 1970-01-01
    • 2011-11-04
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    相关资源
    最近更新 更多