Solved

Mod Rewrite Help

Posted on 2007-12-02
9
225 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

773 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