Your HostICan Community  


Go Back   Your HostICan Community > HostICan Web Hosting > Virtual Private Servers (VPS)

Virtual Private Servers (VPS) Need help with your VPS plan on HostICan? Please feel free to ask and we'll give you the answers!

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-17-2008, 01:09 PM
itwasntme's Avatar
itwasntme itwasntme is offline
Senior Member
 
Join Date: Sep 2007
Posts: 123
Default Rewrite Rule for Changing a URL Variable?

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?
Reply With Quote
  #2  
Old 05-18-2008, 03:55 PM
lnxcode's Avatar
lnxcode lnxcode is offline
The British Kid
 
Join Date: Sep 2007
Location: Richmond, VA
Posts: 1,837
Send a message via AIM to lnxcode Send a message via Skype™ to lnxcode
Default

Hey,

You can do:

Code:
 Redirect 301 /index.php?variable1=blah&Itemid=1 Domain Names, Shared Web Hosting and Site Design Tools - MyDomain
Might work?
__________________
Thanks,

Denis Motova
Affiliate / Operations Manager

HostICan Answers | HostICan Newsletter | HostICan Blog | Become a HostICan Affiliate | Create a Support Ticket.
Reply With Quote
  #3  
Old 05-18-2008, 04:11 PM
itwasntme's Avatar
itwasntme itwasntme is offline
Senior Member
 
Join Date: Sep 2007
Posts: 123
Default

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$  [R=301,L]
However, I think I need something in there to tell it not to match all the Itemid's that just begin with 1, too, otherwise I'll be in an infinite loop as it tries to redirect to Itemid=181, as well as something to include the original URL with the new Itemid value.
Reply With Quote
  #4  
Old 05-18-2008, 04:37 PM
lnxcode's Avatar
lnxcode lnxcode is offline
The British Kid
 
Join Date: Sep 2007
Location: Richmond, VA
Posts: 1,837
Send a message via AIM to lnxcode Send a message via Skype™ to lnxcode
Default

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.
Reply With Quote
  #5  
Old 05-18-2008, 04:48 PM
itwasntme's Avatar
itwasntme itwasntme is offline
Senior Member
 
Join Date: Sep 2007
Posts: 123
Default

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...
Reply With Quote
  #6  
Old 05-18-2008, 04:53 PM
lnxcode's Avatar
lnxcode lnxcode is offline
The British Kid
 
Join Date: Sep 2007
Location: Richmond, VA
Posts: 1,837
Send a message via AIM to lnxcode Send a message via Skype™ to lnxcode
Default

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.
Reply With Quote
  #7  
Old 05-18-2008, 07:05 PM
itwasntme's Avatar
itwasntme itwasntme is offline
Senior Member
 
Join Date: Sep 2007
Posts: 123
Default

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]
It seems to work just fine.
Reply With Quote
  #8  
Old 05-18-2008, 07:09 PM
lnxcode's Avatar
lnxcode lnxcode is offline
The British Kid
 
Join Date: Sep 2007
Location: Richmond, VA
Posts: 1,837
Send a message via AIM to lnxcode Send a message via Skype™ to lnxcode
Default

Quote:
Originally Posted by itwasntme View Post
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]
It seems to work just fine.
I told you that RichardK is the man :P
__________________
Thanks,

Denis Motova
Affiliate / Operations Manager

HostICan Answers | HostICan Newsletter | HostICan Blog | Become a HostICan Affiliate | Create a Support Ticket.
Reply With Quote
Reply

Tags
changing, rewrite, rule, url, variable

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Forum Jump


All times are GMT -4. The time now is 10:05 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

Copyright © 2003 - 2008 HostICan. All Rights Reserved.