Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22nd June 2008, 07:53 PM
CraigWatson's Avatar
CraigWatson Offline
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.
Reply With Quote
  #2  
Old 23rd June 2008, 10:02 PM
BlueC Offline
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.
Reply With Quote
  #3  
Old 23rd June 2008, 11:33 PM
CraigWatson's Avatar
CraigWatson Offline
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
Reply With Quote
Reply

Tags
attributes, htaccess, including, redirects

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DNS Redirects to Subdirectories? CraigWatson Servers & Networking 7 4th July 2008 10:51 AM
http automaticaly redirects to ftp. Why? paparcioziedas Servers & Networking 7 3rd August 2005 08:12 AM


Current GMT-time: 01:06 (Thursday, 20-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat