mod_rewrite有三个参数

时间:2015-06-10 15:24:27

标签: apache .htaccess mod-rewrite

我的网址:

localhost/categories?DPt=MQ==&CTg=MQ==&NLs=Mw==

我想要:

localhost/product-a/departure-a/categories-a/

我的htaccess:

 <IfModule mod_rewrite.c>
   RewriteRule ^confirmation/?$ confirmation.php [NC,L]
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^/?([^/]+)/?$ products.php?PDt2=$1 [QSA,NC,L]
   RewriteRule ^/?categories/([^/]+)/?$ categories.php?DPt=$1&CTg=$2&NLs=$3 [QSA,NC,L]
 </IfModule>

但事实并非如此。 有什么问题?

1 个答案:

答案 0 :(得分:0)

这是我的 .htaccess 版本,其中包含评论:

<IfModule mod_rewrite.c>
   # stop rewrite if matches existing file or directory
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule .* - [L]

   # redirect trailing slash
   RewriteRule ^(.+)/$ /$1 [R=301,L,QSA,NE]

   # confirmation
   RewriteRule ^confirmation$ /confirmation.php [L]

   # match everything except slash to product
   RewriteRule ^([^/]+)$ /products.php?PDt2=$1 [QSA,L]

   # match categories  
   RewriteRule ^(.+)/(.+)/(.+)$ /categories.php?DPt=$1&CTg=$2&NLs=$3 [QSA,L]
</IfModule>