| | |
Mod_Rewrite help!
![]() |
<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
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
StreetLessons.com - My Blog about Business, Life & Success!
Create an .htaccess file in your root directory and put the following:
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).
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).
•
•
Join Date: Jul 2005
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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
•
•
Join Date: Sep 2005
Posts: 9
Reputation:
Solved Threads: 0
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....
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....
•
•
•
•
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*
.
![]() |
Similar Threads
- vBulletin mod_rewrite (PHP)
- Apache mod_rewrite with Google Ads (Linux Servers and Apache)
- mod_rewrite puzzle (Linux Servers and Apache)
- Alternative to using .htaccess for mod_rewrite (Linux Servers and Apache)
- mod_rewrite in asp .net using vb (ASP.NET)
- mod_rewrite (Linux Servers and Apache)
Other Threads in the Linux Servers and Apache Forum
- Previous Thread: .htacess Is Not Working
- Next Thread: IP address not resloved in Apache
| Thread Tools | Search this Thread |
.net apache apple asus bbc bluegene centos cisco citrix cloud cloudcomputing datacenters debian dell desktops development distributions distros drivers economy eeepc energy enterprise fedora fsf gadgets gos government gpl hardware hp hyper-v ibm java jobs kindle knoppix kvm laptop laptops lawsuits ldap limo linustorvalds linux linuxfoundation linuxmagazine magazines microserver microsoft mobile mobilephones netbook netbooks news novell olpc open openmoko openoffice opensolaris opensource opensuse openvz operatingsystems os patents pcworld plathome politics print qumranet redhat rhel robot russia sco server servers slackware software solaris source stallman sun supercomputer support tivo torvalds training tv ubuntu umpc unix virtualization vmware windows x86 xandros xen






