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&TO PIC_ID=213 083
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]+)&whichpa ge=([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>
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
RewriteCond %{QUERY_STRING} FORUM_ID=([0-9]+)
RewriteRule ^forum.asp$ /forum/index.php [R=301,L,QSA]
RewriteCond %{QUERY_STRING} ^TOPIC_ID=([0-9]+)&whichpa
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>
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
ASKER
oh sure sorry about that. With the /forum/index.php?showtopic =213083&TO PIC_ID=213 083 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!
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.
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. :-)
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. :-)
ASKER
Thanks mhs85 but what about a scenario like the one I really need help with?
/forum/index.php?showtopic =213083&TO PIC_ID=213 083 to go to /forum/index.php
/forum/index.php?showtopic
Try adding this:
RewriteCond %{HTTP_HOST} ^yoursite.com/forum/index. php?showto pic=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)
RewriteCond %{HTTP_HOST} ^yoursite.com/forum/index.
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)
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
Thanks!