1

目前,我的 .htaccess 文件看起来像 htis:

IndexIgnore */*
RewriteEngine on
RewriteRule ^add /add.php
RewriteRule ^add/$ add.php
RewriteRule ^sitemap.xml /xmlsitemap.php
RewriteRule ^([^/\.]+)$ /index.php?slug=$1
RewriteRule ^([^/\.]+)/$ /index.php?slug=$1

它适用于以下链接:site.com/category/

但是,我想要 site.com/ 之后的完整 slug。这样我就可以重定向 site.com/category1/subcategory2/subsubcategory3 等。一个类别中可能有未知数量的子类别。

我尝试了 request_uri 但这并没有真正奏效。

这该怎么做?非常感谢!

4

2 回答 2

1

编辑:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* slug.php?%{QUERY_STRING} [L]

这会将 URL 传递给 slug.php

于 2009-06-26T09:25:11.117 回答
0

好的,我知道了。很简单:删除 ^/. 从正则表达式。我只是想这意味着它必须停在任何 / :) 但是......谢谢!现在可以了!:)

于 2009-06-26T10:15:51.140 回答