LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-06-2010, 10:10 PM   #1
eteck
Member
 
Registered: Oct 2003
Location: In a Cave on Mars
Posts: 52

Rep: Reputation: 15
Apache redirect dynamic url


Hi I wish to redirect http://spam.com/index.php?spam=cool to http://spam.com/cool/

I've tried the following in .htaccess:

Code:
RedirectMatch 301 ^(.*)spam=cool$ http://www.spam.com/cool
How doesn't this work? Any ideas how to make it work?
 
Old 07-06-2010, 11:06 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Code:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^spam=cool
RewriteRule  ^/$  /cool? [L]
perhaps ?
 
Old 07-07-2010, 01:00 AM   #3
eteck
Member
 
Registered: Oct 2003
Location: In a Cave on Mars
Posts: 52

Original Poster
Rep: Reputation: 15
Close.

Code:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^spam=cool
RewriteRule  ^(.*)$  /cool? [L]
Does the job. Thx.
 
Old 07-07-2010, 01:08 AM   #4
eteck
Member
 
Registered: Oct 2003
Location: In a Cave on Mars
Posts: 52

Original Poster
Rep: Reputation: 15
What about rewriting a user alias? E.g. http://www.spam.com/~dude to http://www.spam.com, the following doesn't work:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.spam.com/~dude
RewriteRule ^(.*)$ http://www.spam.com/$1 [R=permanent,L]
 
Old 07-07-2010, 11:39 AM   #5
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
I would have though REQUEST_URI would be more suited although you could use mod_userdir. I don't think you can use R=permanent in rewrite rules.
 
Old 07-07-2010, 09:38 PM   #6
eteck
Member
 
Registered: Oct 2003
Location: In a Cave on Mars
Posts: 52

Original Poster
Rep: Reputation: 15
Can you please give an example as I get: "This webpage has a redirect loop." For:

RewriteCond %{REQUEST_URI} !^www.spam.com/~dude
RewriteRule ^(.*) http://www.spam.com/ [R,L]
 
Old 07-07-2010, 10:10 PM   #7
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/~dude
RewriteRule ^(.*) / [L]

Read the docs.

! = does not equal
R forces an external redirect, so the L is never encountered and your second line just goes round in circles.

Last edited by smoker; 07-07-2010 at 10:16 PM.
 
Old 07-07-2010, 10:48 PM   #8
eteck
Member
 
Registered: Oct 2003
Location: In a Cave on Mars
Posts: 52

Original Poster
Rep: Reputation: 15
Didn't work, that http://www.spam.com/~dude redirected me to http://www.spam.com/public_html/~cole
 
  


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
Problem with dynamic url rewrite and redirect in nginx??? gavin2u Linux - Server 3 05-27-2010 10:25 PM
apache redirect url Radioactiveman Red Hat 1 07-29-2009 01:40 PM
How to redirect URL in apache chnlinux Linux - Newbie 1 01-08-2009 04:15 AM
URL redirect in apache maniannam Linux - Server 2 01-05-2009 01:03 AM
Apache Virtual URL Redirect nxny Linux - Software 0 07-19-2002 02:36 PM

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

All times are GMT -5. The time now is 10:10 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