linux - .htaccess 重写重定向路径,但有异常(exception)

标签 linux .htaccess

我想像这样设置我的 htaccess:

RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?slash1=$1&slash2=$2&slash3=$3&slash4=$4 [NC]

但保留某些不应受上述影响的目录,例如domain.com/banana 应该只是domain.com/banana 而不是带有slash1=banana 的index.php。

最佳答案

只需添加 RewriteCond 即可:

RewriteCond %{REQUEST_URI} !^/(banana|oranges|apple)(/.*|)$ [NC]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+) index.php?slash1=$1&slash2=$2&slash3=$3&slash4=$4 [NC,L]

关于linux - .htaccess 重写重定向路径,但有异常(exception),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16878549/

相关文章:

android - 模拟器不关闭 Ubuntu

linux - WSO2 企业移动管理器

.htaccess - htaccess 从不再存在的文件永久重定向

.htaccess - 如何使用 .htaccess 从 URL 隐藏文件夹名称

apache - .htaccess 用分页重写类别

php - htaccess - 使用 php 和 mysql 重写 url

linux - 使用 Gnuplot 在组中显示 Y 标签

php - 如何检查你的代码环境是在 Windows 上还是在 Linux 或其他操作系统上

c++ - 如何获取 C++ 中的包版本? (Linux)

.htaccess - mod_pagespeed : Exclude some directory using htaccess