还有mod_rewrite问题/ .htaccess

时间:2009-09-29 21:29:33

标签: apache .htaccess mod-rewrite friendly-url

我的.htaccess文件中有几个重写规则,一切正常,我想添加一个特定的案例转

sinaesthesia.co.uk/category/psoriasis

sinaesthesia.co.uk/category.php5?category=psoriasis

所以我试过了:

RewriteRule ^(。)category /(.)$ /$1category.php5?category=$2 [L]

哪个不起作用。我已经尝试了它而没有捕获'类别'之前的东西,因为category.php5无论如何都在根,所以它应该在没有它的情况下工作,尝试过:

RewriteRule ^ category /([a-z] +?)$ /category.php5?category=$1 [L]

有和没有捕获类别之前的东西,没有任何作品 - 事实上,我通常得到500错误!这是文件的其余部分:

RewriteEngine On

#remember to change this to aromaclear
RewriteCond %{HTTP_HOST} !^sinaesthesia\.co.uk$ [NC]
RewriteRule ^(.*)$ http://sinaesthesia.co.uk/$1 [R=301,L]

#Translate default page to root
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|html)\ HTTP
RewriteRule ^(.*)index\.(php5|html)$ /$1 [R=301,L]

#translate any .html ending into .php5
RewriteRule ^(.*)\.html$ /$1\.php5  

#change / for ?
RewriteRule ^(.*)\.html/(.*)$ /$1\.html?$2

#strip .html from search res page
RewriteRule ^(.*)search/(.*)$ /$1search_results\.html/search=$2

#translate product details link from search res page
RewriteRule ^products/(.*)/(.*)/(.*)$ /product_details.php5?category=$1&title=$2&id=$3 [L]

#Translate products/psorisis/chamomile-skin-cream-P[x] to productview.php5?id=1
RewriteRule ^products/.*-P([0-9]+) /productview.php5?id=$1 [L]

1 个答案:

答案 0 :(得分:0)

啊:因为我有一个名为category.php5的文件而我正在尝试使用category / psoriasis,服务器会尝试将其解析为category.php5 / psoriasis,但失败了。现在修好了!