0

我有以下重写 URL:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs 
RewriteRule ^(.*)$ index.php?page=$1 [PT,L]

现在我想添加一个例外,如果 URL 类似于 mysite.com/abc 它应该忽略它以及其中的所有内容。mysite.com/abc/dfgs 也应该被排除在这种重写之外。

我怎样才能做到这一点?

4

2 回答 2

2

如果 /abc 是现有目录,您可以在其中放置另一个 .htaccess 文件

RewriteEngine Off  

如果它真的只是一个你不想重写的字符串(无论它是否存在)

RewriteCond %{REQUEST_URI} !^/abc  

如果请求的路径以“/abc”开头,则不会重写

为了测试重写规则而不会弄乱常规浏览器的站点(当然不是说您应该在实时环境中进行编辑,这纯粹是假设的:-)),我发现以下内容非常有用:

RewriteCond %{REMOTE_ADDR} 12.34.56.78 # <-- where that's your IP address  
于 2009-06-28T17:50:31.683 回答
0

如果 URI 包含 abc,这应该避免重写。这可能是也可能不是你想要的。如果不是编辑您的问题。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Rewrite ONLY if the REQUEST does NOT contain abc
RewriteCond %{REQUEST_URI} !abc

# Rewrite all other URLs 
RewriteRule ^(.*)$ index.php?page=$1 [PT,L]
于 2009-06-28T17:29:27.573 回答