?
Solved

URL Rewrite

Posted on 2007-11-28
10
Medium Priority
?
410 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
Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

762 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