 |
 |
 |
 |
| Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc. |

22nd June 2008, 07:53 PM
|
 |
Registered User
|
|
Join Date: Jan 2008
Location: Witham, Essex, UK
Age: 25
Posts: 341

|
|
|
.htaccess Redirects - Including GET attributes
I'm not sure which forum fits this question better - Servers or Programming but feel free to move it if it's needed.
The problem I'm having is this: I've just re-organised some of my website's pages, and the page www.site.com/index.php?page=2007script is now www.site.com/scripts.php?year=2007. I've already tried writing a .htaccess redirect, but this only looks for the filename and not any attributes after it, so for example:
Code:
Redirect 301 /index.php?page=2007script http://www.site.com/scripts.php
Has anybody got any suggestions as to how I can write the redirect how I want it?
Cheers,
Craig
__________________
Personal Website | Windows to Linux - Tips from Experience
Desktop - Galileo
Dual-Boot: Fedora 13 x64, Windows 7 x64
Intel Core2Quad Q6600 @3.6GHz, 8GB PC2-8500 DDR2, ATI HD4870, 23" @ 1920x1080 + 20" @ 1600x900 (both DVI-D), 2TB ICH10R RAID0 array, Custom Watercooling
Laptop - MacBook 5.1 ('08 Aluminium)
Dual-Boot: Fedora 13 x64, Apple OS X
Intel Core2Duo, 2GB 1066MHz DDR3, nVidia 9400M, 13" LCD @ 1280x800, 160GB SATA
Last edited by CraigWatson; 22nd June 2008 at 07:57 PM.
|

23rd June 2008, 10:02 PM
|
|
Registered User
|
|
Join Date: Aug 2007
Location: Liverpool, UK
Posts: 733

|
|
You need to use RewriteCond with the QUERY_STRING parament.
Basically you want something like this:
Code:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} page=2007script
RewriteRule ^index.php(.*) scripts.php?year=2007
That should do the trick.
If you also have other years, like index.php?page=2006script -> scripts.php?year=2006 then you could get a bit clever and use something like this:
Code:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} page=([0-9]*)script
RewriteRule ^index.php(.*) scripts.php?year=%1
HTH
Last edited by BlueC; 23rd June 2008 at 10:05 PM.
|

23rd June 2008, 11:33 PM
|
 |
Registered User
|
|
Join Date: Jan 2008
Location: Witham, Essex, UK
Age: 25
Posts: 341

|
|
Awesome, that did the trick - cheers!
The only tweak I made was changing the last line to this:
Quote:
|
RewriteRule ^index.php(.*) scripts.php?year=%1 [R=301]
|
So that the URL is displayed as the new URL.
Many thanks
__________________
Personal Website | Windows to Linux - Tips from Experience
Desktop - Galileo
Dual-Boot: Fedora 13 x64, Windows 7 x64
Intel Core2Quad Q6600 @3.6GHz, 8GB PC2-8500 DDR2, ATI HD4870, 23" @ 1920x1080 + 20" @ 1600x900 (both DVI-D), 2TB ICH10R RAID0 array, Custom Watercooling
Laptop - MacBook 5.1 ('08 Aluminium)
Dual-Boot: Fedora 13 x64, Apple OS X
Intel Core2Duo, 2GB 1066MHz DDR3, nVidia 9400M, 13" LCD @ 1280x800, 160GB SATA
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Current GMT-time: 01:06 (Thursday, 20-06-2013)
|
|
 |
 |
 |
 |
|
|