开发者

adding a parameter to a url that has a mod_rewrite value

I have a rewirte rule that rewrites my portfolio urls from portfolio.php?cat=cat-name&project=project-slug to /portfolio/cat/slug/

That all works fine and dandy, I'm wondering if It's possible to add a parameter to the end of the rewritten slug. For example

/portfolio/cat/slug&preview=true

I'm trying to make it so I can preview hidden projects by appending the preview=true to the end. It works if I go to portfolio.php?cat=cat-name&project=project-name&preview=true

I'm just hoping I don't have to create a rule that has /true I've tied various ways to get the value or preview but thought someone here may have a simple solution

Edit Adding .htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^.*$
#portfolio
RewriteRule ^portfolio/?$ portfolio.php [L,NC]
RewriteRule ^portfolio/(开发者_运维问答[a-z0-9_-]+)/([a-z0-9_-]+)/?$ portfolio.php?cat=$1&project=$2 [L,NC]
RewriteRule ^portfolio/([a-z0-9_-]+)/?$ portfolio.php?cat=$1 [L,NC]
RewriteRule ^portfolio/([a-z0-9_-]+)/page=([0-9]+)/? portfolio.php?cat=$1&page=$2&


Add QSA as an option to the back of the RewriteRule (in the [] brackets). E.g.

RewriteRule ^portfolio/([a-z0-9_-]+)/([a-z0-9_-]+)/?$ portfolio.php?cat=$1&project=$2 [L,NC,QSA]


Please look at http://www.workingwith.me.uk/articles/scripting/mod_rewrite for such an example. You may also include a hidden field with that appropriate value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜