hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : mod_rewrite weirdness
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

mod_rewrite weirdness

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 06-01-2005, 01:49 AM
JPortal JPortal is offline
Junior Guru Wannabe
 
Join Date: Jul 2003
Posts: 70

mod_rewrite weirdness


mod_rewrite is a great tool but the regex syntax is bizarre.

Basically, I'm moving to a new site and I need to redirect users to new pages. If someone goes to: "index.php?name=Forums&file=viewtopic&t=854"
I need to redirect them to "/bb/viewtopic.php?t=854"

This is my code thus far:
Code:
RewriteRule ^(.*)index.php\?(.*)$ /bb
This is NOT WORKING! Obviously it's a bit bare, but if you go to "index.php?name=Forums&file=viewtopic&t=854"
it does not get redirected. As soon as I remove that last question mark (and the backslash) it starts redirecting again... what am I doing wrong? Is there some weird way to escape question marks?

__________________
Looking for a good drop down menu? Try WebDDM, the only flexible open source solution
http://www.jportalhome.com/bb/viewtopic.php?p=3177#3177

Reply With Quote


Sponsored Links
  #2  
Old 06-02-2005, 04:14 PM
Koobi Koobi is offline
WHT Addict
 
Join Date: Jun 2004
Posts: 109
I don't remember the exact sentence for mod_rewrite but here's the regex to capture the numerical values for _GET['t']

Code:
index\.php\?name=[a-zA-Z]+&file=[a-zA-Z]+&t=([0-9]+)
\\1 hold the number so you could use that for the redirecting.

Hope it helps

Reply With Quote
  #3  
Old 06-02-2005, 06:47 PM
maxymizer maxymizer is offline
Web Hosting Evangelist
 
Join Date: Apr 2005
Posts: 521
Your regexp in RewriteRule is invalid.
To redirect from/bb/viewtopic.php?t=854 to index.php?name=Forums&file=viewtopic&t=854 use the following:

RewriteRule ^/bb/viewtopic&t=([0-9]+)$ /index.php?name=Forums&file=viewtopic&t=$1 [L]

Reply With Quote
Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Open Source Hosting - Challenges and Opportunities for Service Providers Web Hosting News 2012-12-10 10:33:18
ProfitBricks Says its New “Next Generation Cloud” Outperforms Amazon, Rackspace Web Hosting News 2012-09-10 16:35:00
Web Host WebHostForASP.net Launches VPS Hosting Service Web Hosting News 2012-06-29 14:52:22
Q&A: Toby Owen on Rackspace's Updated Hybrid Cloud Solution Web Hosting News 2011-11-08 21:31:27


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?