2009-06-26 55 views
1

目前,我的.htaccess文件看起來像htis:條件規則的htaccess

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/

但是,我想現場後完全蛞蝓.COM /。因此,我可以重定向site.com/category1/subcategory2/subsubcategory3等。類別內可能有未知數量的子類別。

我嘗試request_uri,但那並沒有真正解決。

如何做到這一點?謝謝一堆!

回答

0

好,知道了。這很簡單:刪除^ /。來自正則表達式。我只是覺得這意味着它必須停止在任何/ :)但... thx!它現在有效! :)

1

編輯:

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

這將通過URL來slug.php

+0

thx!然而,如果我這樣做,我得到:http://www.domain.com/index.php?slug=index.php – 2009-06-26 09:28:04