Solved

Mod Rewrite Help

Posted on 2007-12-02
9
222 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now