【问题标题】:How to remove part of URL and exclude path from rewriting in .htaccess?如何从 .htaccess 中的重写中删除部分 URL 并排除路径?
【发布时间】:2016-03-05 17:55:44
【问题描述】:

我的 .htaccess 中有这个:

RewriteEngine on 
RewriteRule !^/clients/index.php
RewriteRule ^clients/(.*) $1/$2

想法是用 URL 中的客户端重写所有 url(例如 mydomain.com/clients/cart.phpmydomain.com/cart.php)但排除此规则适用于 mydomain.com/clients/index.php

使用上述规则,没有我的排除规则可以正常工作,但是当我添加 RewriteRule !^/clients/index.php 规则给了我内部服务器错误。

问题是如何排除重写的完整路径?

【问题讨论】:

    标签: apache .htaccess mod-rewrite


    【解决方案1】:

    改变

    RewriteRule
    !^/clients/index.php
    

    RewriteCond %{REQUEST_URI} !^/clients/index.php
    

    重写:

    RewriteEngine on 
    RewriteCond %{REQUEST_URI} !^/clients/index.php
    RewriteRule ^clients/(.*) $1/ [NC,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-27
      • 1970-01-01
      相关资源
      最近更新 更多