Link to home
Start Free TrialLog in
Avatar of vfetty
vfetty

asked on

Mod Rewrite Help

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>
Avatar of mhs85
mhs85
Flag of United States of America image

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
Avatar of vfetty
vfetty

ASKER

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!
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.
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. :-)
Avatar of vfetty

ASKER

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
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)
Avatar of vfetty

ASKER

Hmmm, that did not work for me and I am not sure why?  does not forward just seems to ignore that rule?
ASKER CERTIFIED SOLUTION
Avatar of mhs85
mhs85
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vfetty

ASKER

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!