943,678 Members | Top Members by Rank

Feb 19th, 2005
0

Mod_Rewrite help!

Expand Post »
<no0ob alert> The only experience I have with mod_rewrite is to upload all the rules generated by wordpress or those by my ultra helpful friends :o </noob alert>

Here's what I want to do -

every request made for http://www.domain.com/forumdisplay.php?t=xyz and http://www.domain.com/showthread.php?t=xyz should be redirected to http://www.domain.com/forums/forumdisplay,php?t=xyz and http://www.domain.com/forums/showthread.php?t=xyz respectively!

:mrgreen: Can someone help me with the rules?

Thanks
Similar Threads
Reputation Points: 11
Solved Threads: 0
Junior Poster
pulse is offline Offline
157 posts
since Aug 2004
Feb 19th, 2005
0

Re: Mod_Rewrite help!

Create an .htaccess file in your root directory and put the following:

Options +FollowSymLinks
RewriteEngine on
 
RewriteRule ^forumdisplay.php?f=([0-9]+)$ ./forums/forumdisplay.php?f=$1 [R=301, L]
RewriteRule ^showthread.php?t=([0-9]+)$ ./forums/showthread.php?t=$1 [R=301, L]

Let's examine the first rule. It says that when you see a URL in the form of forumdisplay.php?f=some number, redirect to ./forums/forumdisplay.php?f=X where X is whatever the number just happens to be. The R=301 part means to do a 301 Redirect Permanent on the URL, which basically means that the content has moved from the old location to the new location, so pass any Google PR, etc. to the new URL. The L part means (to the best of my knowledge) that if a URL qualifies for this rule, apply it and then stop parsing the .htaccess file. (i.e. don't continue following other rules, because the URL will not apply to multiple rules in this file).
Administrator
Staff Writer
Reputation Points: 1422
Solved Threads: 162
The Queen of DaniWeb
cscgal is offline Offline
13,645 posts
since Feb 2002
Jul 19th, 2005
0

Re: Mod_Rewrite help!

Quote originally posted by cscgal ...
Create an .htaccess file in your root directory and put the following:

Options +FollowSymLinks
RewriteEngine on
 
RewriteRule ^forumdisplay.php?f=([0-9]+)$ ./forums/forumdisplay.php?f=$1 [R=301, L]
RewriteRule ^showthread.php?t=([0-9]+)$ ./forums/showthread.php?t=$1 [R=301, L]

Let's examine the first rule. It says that when you see a URL in the form of forumdisplay.php?f=some number, redirect to ./forums/forumdisplay.php?f=X where X is whatever the number just happens to be. The R=301 part means to do a 301 Redirect Permanent on the URL, which basically means that the content has moved from the old location to the new location, so pass any Google PR, etc. to the new URL. The L part means (to the best of my knowledge) that if a URL qualifies for this rule, apply it and then stop parsing the .htaccess file. (i.e. don't continue following other rules, because the URL will not apply to multiple rules in this file).

Hi,

Ive been trying to adapt this rule for my site and having very little luck

Our URL stucture is;

/dir/?pid=example

We ideally want that rewrote into;

/dir/example

Any help or advice is appreciated.

Matt
Reputation Points: 10
Solved Threads: 0
Newbie Poster
msmartinwsx is offline Offline
1 posts
since Jul 2005
Sep 21st, 2005
0

Re: Mod_Rewrite help!

What is the word on how effective this is as far google picking up on the url change and preserving the rewritten url with it's old status in the index?
I posted another question regarding how to accomplish a rewrite rule earlier today, hopfully some help will arrive for that, but this 301 thing would be great to be able to tidy up my indexed stuff - I was just going to slowly transition stuff out before....

Quote originally posted by cscgal ...
*snip*
The R=301 part means to do a 301 Redirect Permanent on the URL, which basically means that the content has moved from the old location to the new location, so pass any Google PR, etc. to the new URL.
*snip*

.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bsmith is offline Offline
9 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Linux Servers and Apache Forum Timeline: .htacess Is Not Working
Next Thread in Linux Servers and Apache Forum Timeline: IP address not resloved in Apache





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC