如何在 htaccess 中为 url 设置重写条件


How to set rewrite condition for url in htaccess

>我有下面的网址。

http://localhost/testing/images/Latest+Images/In+Golden+Light/golden

现在我需要在 htaccess 中重写这种类型的 url
的条件现在我想获取类别名称(最新+图像)和标题名称(In+金色+浅色)搜索条件是(金色)来自此 URL。我怎样才能得到这个?
任何人都可以给我这个问题的答案。

您可以使用

以下简单的重写规则将所有 url 重定向到索引.php:

RewriteEngine on  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule ^(.*) index.php?url=$1 [L,QSA]  

然后使用分解函数拆分网址:

$parts = explode("/",$_GET['url']);

现在类别名称在$parts[2]中,标题名称在$parts[3]中,搜索条件在$parts[4]中。

(假设所有链接正好有 5 个部分)