LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-16-2010, 07:42 AM   #1
kevin-fdc
LQ Newbie
 
Registered: Mar 2010
Posts: 2

Rep: Reputation: 0
Post Using question marks in mod_rewrite


Hi There,

We have a website that has pages which dont exist any more and i'm trying to redirect the old link to the homepage. This works for most rules but once I include a ? in the link it doesnt work.

Heres and example of a working one I have:
Code:
RewriteRule ^email-marketing\.php$ http://www.example.co.uk/ [R=301,L]
Now as soon I do something like this:
Code:
RewriteRule ^index\.php\?page=contact$	http://www.example.co.uk/
it doesnt pick it up / work. I cannot find anything helpful in the log either

Ive also tried this that doesnt work:
Code:
RewriteCond ${QUERY_STRING} 	=^index.php?page=contact$
RewriteRule ^index\.php\?page=contact$	http://www.example.co.uk/
this does also not work.

Im sure i'm missing something simple here. Any help / advice would be greatly appreciated
 
Old 03-16-2010, 09:02 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Quote:
Originally Posted by kevin-fdc View Post
Ive also tried this that doesnt work:
Code:
RewriteCond ${QUERY_STRING} 	=^index.php?page=contact$
RewriteRule ^index\.php\?page=contact$	http://www.example.co.uk/
this does also not work.
Try
Code:
RewriteCond %{QUERY_STRING} ^page=contact$
RewriteRule ^index.php http://www.example.co.uk/
 
Old 03-16-2010, 10:36 AM   #3
kevin-fdc
LQ Newbie
 
Registered: Mar 2010
Posts: 2

Original Poster
Rep: Reputation: 0
This brings me no luck I just receive the 404 not found
 
Old 03-16-2010, 10:44 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
You have specified a real address in the RewriteRule ?

try putting a slash in front of index.php
Code:
RewriteCond %{QUERY_STRING} ^page=contact$
RewriteRule ^/index.php http://www.example.co.uk/
 
Old 03-16-2010, 04:24 PM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You should add a "?" at the end of the rewrited address, so the QUERY_STRING does not append to it:
Code:
RewriteCond %{QUERY_STRING} ^page=contact$
RewriteRule ^index.php http://www.example.co.uk/?
Regards
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question marks in the directory attributes, need help fixing. jason143 Linux - Software 5 06-22-2009 01:17 AM
question marks show when doing ll abylin1 Linux - Newbie 9 01-15-2008 02:54 PM
Two question marks next to unopened messages in KMail Aleksandersen Linux - Desktop 1 02-11-2007 06:14 PM
Quotes as Question Marks in Thunderbird. Matir Linux - Software 2 07-11-2005 02:54 PM
Apache Changing Quotes to Question Marks tictocdoc Linux - Networking 3 05-16-2004 12:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration