Solved

URL Rewrite

Posted on 2007-11-28
10
387 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
  • 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
 

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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

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.
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…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now