Solved

Mod Rewrite Help

Posted on 2007-12-02
9
234 Views
Last Modified: 2010-03-04
Hi, I need some help to get my site redirecting properly after a forum/site switch over. Here is the code I currently use but I need to forward type of request also /forum/index.php?showtopic=213083&TOPIC_ID=213083

Plus just a general rule, to forward from say an old folder /GVB/ to /articles/ on the site.  I really don't know what I am doing I just got this code as a sample and revised. help!:)

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteBase /
   RewriteCond %{QUERY_STRING} TOPIC_ID=([0-9]+)
   RewriteRule ^topic.asp$ /forum/index.php?showtopic=%1 [R=301,L,QSA]
   RewriteCond %{QUERY_STRING} FORUM_ID=([0-9]+)
   RewriteRule ^forum.asp$ /forum/index.php [R=301,L,QSA]
   RewriteCond %{QUERY_STRING} ^TOPIC_ID=([0-9]+)&whichpage=([0-9]+)
   RewriteRule ^forum.asp$ /forum/index.php [R=301,L,QSA]
   RewriteCond %{QUERY_STRING} whichpage=([0-9]+)
   RewriteRule ^forum.asp$ /forum/index.php [R=301,L,QSA]
</IfModule>
0
Comment
Question by:vfetty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 3

Expert Comment

by:mhs85
ID: 20391924
Please be more specific with EXACTLY what you want to do.  Example: When a user types http://www.yoursite.com/whatever, they should be redirected to http://www.yoursite.com/adifferentplace
0
 

Author Comment

by:vfetty
ID: 20391981
oh sure sorry about that.  With the /forum/index.php?showtopic=213083&TOPIC_ID=213083 just want to take them to /forum/index.php (http://yoursite.com/forum/index.php).

http://www.yoursite.com/whatever (in this case it's called http://www.yoursite.com/GVB/ to go to http://www.yoursite.com/articles

or

http://www.yoursite.com/whatever to go to http://www.yoursite.com/

Please let me know if you need anything else from me. Thanks!
0
 
LVL 3

Expert Comment

by:mhs85
ID: 20392038
Make a text file called ".htaccess" (not ".htaccess.txt") and place it in the public_html/ folder of your website (the root directory).

In the blank file, add these lines:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com/GVB [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/articles [L,R=301]
RewriteCond %{HTTP_HOST} ^yoursite.com/whatever [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/ [L,R=301]

That should do what you are looking for in the bottom 2 examples.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 3

Expert Comment

by:mhs85
ID: 20392046
Also, for future help, please take a look at these three sites:
http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm
http://httpd.apache.org/docs/1.3/howto/htaccess.html
http://www.webweaver.nu/html-tips/web-redirection.shtml

You will find everything you need to know between them. :-)
0
 

Author Comment

by:vfetty
ID: 20392497
Thanks mhs85 but what about a scenario like the one I really need help with?

/forum/index.php?showtopic=213083&TOPIC_ID=213083 to go to /forum/index.php
0
 
LVL 3

Expert Comment

by:mhs85
ID: 20392569
Try adding this:

RewriteCond %{HTTP_HOST} ^yoursite.com/forum/index.php?showtopic=213083&TOPIC_ID=213083 [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/forum/index.php [L,R=301]

(just a guess, but if it works, great, if not, i'll do more research)
0
 

Author Comment

by:vfetty
ID: 20392663
Hmmm, that did not work for me and I am not sure why?  does not forward just seems to ignore that rule?
0
 
LVL 3

Accepted Solution

by:
mhs85 earned 500 total points
ID: 20392718
probably because of the strange characters in the string like ?, =, _, &, etc...will have to do more research on how to embed those
0
 

Author Comment

by:vfetty
ID: 20401267
ok mhs85 got that one fixed, last question I promise.  What about something like this http://myurl.com/articles/fishing.asp to http://myurl.com/newarticles/fishing.asp

Thanks!
0

Featured Post

Limited time offer using promo code EXPERTS25

Designed with a wealth of functionality and convenience, ATEN's new Thunderbolt™ 2 Sharing Switch takes your Thunderbolt setup to the next level. Now through August 31, 2017, Experts Exchange members get 25% off the US7220 on the ATEN USA eShop using promo code EXPERTS25.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question