Solved

URL Rewrite

Posted on 2007-11-28
10
399 Views
Last Modified: 2010-05-18
Hi, This is what I am looking to do since I changed from a forum with asp to php.

rewrite the old URL variables to the new ones that my current forum uses.

ie. old incoming url: http://my_domain/forum.asp?FORUM=2

or

ie old url http://my_domain/forum.asp?TOPIC_ID=32324

Take those turn them into this:

http://my_domain/forums/index.php?showforum=2

http://my_domain/forums/index.php?showtopic=32324

Appreciate the help. I'm a total n00b with this stuff:)
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
10 Comments
 
LVL 2

Expert Comment

by:accrain
ID: 20370787
Rename the class in the code; FORUM to "showforum" and TOPIC_ID to "showtopic".
0
 
LVL 10

Expert Comment

by:wildzero
ID: 20371139
RewriteEngine on
RewriteBase /
RewriteRule ^forum.asp?FORUM=([0-9]+)$ /index.php?showforum=$1 [QSA,L]
RewriteRule ^forum.asp?TOPIC_ID=([0-9]+)$ /index.php?showtpic=$1 [QSA,L]

or, and probly the better way is to change QSA to R=301 like

RewriteEngine on
RewriteBase /
RewriteRule ^forum.asp?FORUM=([0-9]+)$ /index.php?showforum=$1 [R=301,L]
RewriteRule ^forum.asp?TOPIC_ID=([0-9]+)$ /index.php?showtpic=$1 [R=301,L]

and just stick that in an htaccess file in your document root.
If that dosn't work, change
([0-9]+)
to
(.+)
0
 
LVL 10

Expert Comment

by:wildzero
ID: 20371144
/index.php?showtpic=$1
should be
/index.php?showtopic=$1
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vfetty
ID: 20371419
this one note working

RewriteEngine on
RewriteBase /forum/
RewriteRule ^forum.asp?FORUM=([0-9]+)$ /index.php?showforum=$1 [R=301,L]
RewriteRule ^topic.asp?TOPIC_ID=([0-9]+)$ /index.php?showtopic=$1 [R=301,L]
0
 

Author Comment

by:vfetty
ID: 20371433
sorry was in a rush last time, thanks for the replies here is what it says in the 404

Not Found

The requested URL /forum/topic.asp was not found on this server.
0
 

Author Comment

by:vfetty
ID: 20372039
I looked over my response again and noticed I changed the RewriteBase to /forum/ since that is where my forum is located.  The issue is still happing when google comes from a search it 404's?  Please really need help!
0
 
LVL 10

Expert Comment

by:wildzero
ID: 20377355
Right first thing to look at is if apache is reading the .htaccess
Edit the .htaccess and just write junk in there, like
RewriteRule asdf^forum.asp?FORUM=([0-9asdf]+)$ /index.php?showforum=$1 [R=301,L]asdf

this should throw a 500 internal server error

If it does then we are on the right course, this .htaccess is in the document root folder? Do you have another .htaccess which is in your /forum/ folder?

And just to check, your folder structure was
/forum/topic.asp
and is now
/forum/topic.php?

if so I would suggest changing the htaccess to
RewriteEngine on
RewriteBase /
RewriteRule ^forum/forum.asp?FORUM=([0-9]+)$ /forum/index.php?showforum=$1 [R=301,L]
RewriteRule ^forum/topic.asp?TOPIC_ID=([0-9]+)$ /forum/index.php?showtopic=$1 [R=301,L]

the missing of the/ before forum at the station is intentional
0
 

Author Comment

by:vfetty
ID: 20377398
below is what I have been using that worked but I have another scenerio I do not know how to do:

/forum/topic.asp?TOPIC_ID=134385&whichpage=4

the whichpage=4 - how do I pick up that one.

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteBase /
   RewriteCond %{QUERY_STRING} TOPIC_ID=([0-9]+)
   RewriteCond %{QUERY_STRING} FORUM=([0-9]+)
   RewriteRule ^topic.asp$ /forum/index.php?showtopic=%1 [R=301,L,QSA]
   RewriteRule ^forum.asp$ /forum/index.php [R=301,L,QSA]
</IfModule>
0
 
LVL 10

Accepted Solution

by:
wildzero earned 500 total points
ID: 20377507
with the new php site, what is the equlviant of TOPIC_ID=134385&whichpage=4 ?
index.php?showtopic=134385&page4?

RewriteRule ^forum/topic.asp?TOPIC_ID=([0-9]+)&whichpage=([0-9+)$ /forum/index.php?showtopic=$1&page=$2 [R=301,L]
0
 

Author Comment

by:vfetty
ID: 20377923
actually after thinking about it I just need anytime TOPIC_ID=134385&whichpage=4 is present just to go to forum/index.php  . How would I do that?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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.

737 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