Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mod Rewrite Help

Posted on 2007-12-02
9
Medium Priority
?
236 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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 1500 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 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