1

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&
0

2 Answers 2

3

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]

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! I knew it was probally something simple but mod_rewrite is voodo to me :)
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.