![]() |
|
|
|
|
|||||||
| Virtual Private Servers (VPS) Need help with your VPS plan on HostICan? Please feel free to ask and we'll give you the answers! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
I need a RewriteRule in .htaccess to change a URL variable's value and I am having a hard time coming up with the correct syntax. What I need to do is take any URL that includes the variable Itemid=1 and change it to Itemid=181.
For example, say a user comes in with a URL like this: "http://www.mydomain.com/index.php?variable1=blah&Itemid=1" I need the user to be redirected to: "http://www.mydomain.com/index.php?variable1=blah&Itemid=181" The number of variables prior to Itemid may vary. Everything I have tried thus far has the server thinking that Itemid is a folder. What would be the correct syntax? |
|
#2
|
||||
|
||||
|
Hey,
You can do: Code:
Redirect 301 /index.php?variable1=blah&Itemid=1 Domain Names, Shared Web Hosting and Site Design Tools - MyDomain
__________________
Thanks, Denis Motova Affiliate / Operations Manager HostICan Answers | HostICan Newsletter | HostICan Blog | Become a HostICan Affiliate | Create a Support Ticket. |
|
#3
|
||||
|
||||
|
Hi Denis,
I think you discovered what I discovered with this bulletin board: it's got some protection for using "http:" in a [code] or [quote] tag that converts it to an unrelated link. My problem is that the number of variables preceding the Itemid=1 may vary, and their names may vary. I can't even guarantee that the Itemid will be the last variable. I'm using mod_rewrite in .htaccess, by the way. So far I have: Code:
RewriteRule ^Itemid=1$ |
|
#4
|
||||
|
||||
|
I would suggest you go to modrewrite.com and see if their community forum there can help? - They should be able to... ?
__________________
Thanks, Denis Motova Affiliate / Operations Manager HostICan Answers | HostICan Newsletter | HostICan Blog | Become a HostICan Affiliate | Create a Support Ticket. |
|
#5
|
||||
|
||||
|
Thanks, I have posted on modrewrite.com, but haven't heard anything yet. The poor guy who owns that forum is getting spammed to death. There are probably 10 spam posts for every one legitimate one...
|
|
#6
|
||||
|
||||
|
Yea, thats true. Well, he does use phpbb - he may want to try phpbb3 or perhaps vBulletin?
__________________
Thanks, Denis Motova Affiliate / Operations Manager HostICan Answers | HostICan Newsletter | HostICan Blog | Become a HostICan Affiliate | Create a Support Ticket. |
|
#7
|
||||
|
||||
|
Man, I would have never figured this out! Here's the solution I got from modrewrite.com:
Code:
# Match itemid=1 in the query string.
RewriteCond %{QUERY_STRING} ^((.*&)?itemid=1)(&.*)?$ [NC]
# Match the correct file. Redirect (adding 94).
RewriteRule ^(index\.php)$ /$1?%194%3 [R=301,L]
|
|
#8
|
||||
|
||||
|
Quote:
__________________
Thanks, Denis Motova Affiliate / Operations Manager HostICan Answers | HostICan Newsletter | HostICan Blog | Become a HostICan Affiliate | Create a Support Ticket. |
![]() |
| Tags |
| changing, rewrite, rule, url, variable |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|