Forum Moderators: phranque
right now ive got
website.com/our_products/
redirecting to
index.php?page=our_products
the problem is i want to be able to accept
website.com/our_products/?search=true&product_id=1&stuff=this
so in my htaccess file ive tried this but cant seem to get it to work
RewriteRule ^([0-9a-zA-z]+)/$ index.php?page=$1 [NC]
how would i write an exception so that i could accept this?
ive tried this too
rewriteRule ^our_products([^&]*)$ index.phtml?page=our_products$1
All you've told us is "I wrote this code and it doesn't work." That's not highly-useful.
What URL did yo type in?
What result did you expect?
What result did you get?
In as much detail as possible, how did those results differ from your expectations?
Was there anything in your server error log?
Did anything appear incorrect in your server access log?
As for the larger question, please show us a good list of the URLs you want to rewrite -- showing as much variation as possible, so that we can tell which parts of the URLs are fixed, which are variable, and what the acceptable "range" of variation is -- for example, are they numbers? Letters? Upercase and lowercase letters or just lowercase? Mixed letters and numbers? Any hyphens or underscores in them? What about parameter order... Is it fixed or variable. Are some parameters always present in the requested URL, while some may not be there?
You'll get the best answers by providing the information needed to determine the best answers...
Generally, you will need one rule for each possible URL format. You can start with the longest format, get that working, and then remove pieces to create the shorter rules for the shorter formats, or you can go the other way, starting with the shortest format, and building up.
Jim
That may actually be all that's needed here.
Jim
im am trying to use .htaccess url rewrite
-the site is displaying products
-after the user searches I want the form to send "get" data instead of "post"
so i need to get a link like this to work
[thewebsite.com...]
id like to re-write it in the following way
index.php?page=products&search=true&id=4
or another way to say this
index.php?page=productss& anything else here
rewriteCond %{QUERY_STRinG} ^/?sub=true$
RewriteRule ^our_products/(.*)$/index.phtml?page=our_products&sub=true&$1 [L]
i want everything after /our_products/?sub=true
to be carried over add added onto this
/index.phtml?page=our_products&sub=true
so again
/our_products/?sub=true[everything after]
rewrite to
/index.phtml?page=our_products&sub=true[everything after]
.
The rule can never run, because a Query String would never begin with a / and your pattern is also saying that sub=true is the only query string parameter present (because you both start and end anchored it):
^/?sub=true$ You might try
&?sub=true&? or similar. .
Also be aware that the RewriteRule line itself cannot 'see' the query string data, so the (.*) backreference likely doesn't capture what you think it might.
- used a relative link for the images, so the browser is resolving the URL for those incorrectly,
- not restricted the URL formats that your rewrite responds to, and the image requests are also, incorrectly, being rewritten.
In both of your rules, the $1 usage is likely incorrect, and in one rule there is no way that it could ever work as you never created any backreference.
Back-references %1-%9 refer to the part of the variable test-string matching the the first through ninth parenthesized sub-pattern of the last-matched RewriteCond pattern.
Jim