LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-15-2011, 09:56 AM   #1
johngiggs
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Rep: Reputation: Disabled
Apache redirect for URL with encoded characters


I have a URL that I'm trying to redirect back to the homepage on my site. For some reason since it contains hex I can't seem to get it to work.

A sample source URL is:


http://mydomain.com/by/topic/net/pag...age%2F8/page/7

The destination URL is:

http://mydomain.com

I've tried many different things to no avail. Some things include:

RewriteRule ^/(.*)REG_LOGINfromURL(.*) http://mydomain.com [L,R=301]

RewriteRule REG_LOGINfromURL http://mydomain.com [R=301]

Some tests with RewriteMap escape int:escape.

Nothing has worked thus far.

Can someone please help me out?

Redirecting source URLs with REG_LOGINfromURL will get me what I need. Some of my examples work when the source URL does not contain enconded characters, so if the URL was instead http://mydomain.com/by/topic/net/pag...ttp://test.com it would redirect.

I'm running RHEL 4 and Apache/2.0.52.

Thanks,

John
 
Old 06-16-2011, 06:06 AM   #2
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
Hi and welcome to LQ,

For this to work, you'll need:
Code:
AllowEncodedSlashes On
into httpd.conf or a vhost part.
Note that according to the documentation, it should work for both, but it didn't for me (apache 2.2.19). I had to put it into a <VirtualHost>...</VirtualHost> definition
Then you can use your rule (without the leading slash after ^):
Code:
RewriteRule ^(.*)REG_LOGINfromURL(.*) http://mydomain.com [L,R=301]
Regards
 
1 members found this post helpful.
Old 06-16-2011, 09:58 AM   #3
johngiggs
LQ Newbie
 
Registered: Jun 2011
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thank you!

Thanks bathory! That's exactly what I needed. I was trying to figure it out for a long time to no avail.

I just tested it on a VH and it worked perfectly.

Thank you for your help!

John
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
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 URL redirect problem kdogksu Linux - Networking 2 03-26-2005 02:22 PM
Apache Virtual URL Redirect nxny Linux - Software 0 07-19-2002 02:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:10 AM.

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