• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 567
  • Last Modified:

.htaccess redirect with spaces in the URL or %20

I've been on Google for hours and I can't seem to find a way to redirect the foolowing URL's from one domain to another different domain via .htaccess...
 
http://www.Domain1.co.uk/vacancies_apply.html?id=88&Source=Word%20Space
http://www.Domain1.co.uk/vacancies_apply.html?id=88&Source=Jobsite
http://www.Domain1.co.uk/vacancies_apply.html?id=88&Source=Reed
http://www.Domain1.co.uk/vacancies_apply.html?id=88&Source=Another%20Word
http://www.Domain1.co.uk/vacancies_apply.html?id=88&Source=MyJobGroup

All to :
http://www.Domain2.org/who-we-are/work-for-us/

I'm no .htaccess expert and what I've tried so far doesn't work...

I thought maybe it's because of the spaces in the URL...but turns out I can't get any of the  301 redirects methods to work...can anyone help?
0
m-higgins
Asked:
m-higgins
  • 5
  • 3
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
Post what you have tried so far.
0
 
m-higginsAuthor Commented:
Lots of variations of mostly the same method - here are just a couple that I tried.

RedirectMatch 301 /vacancies_apply.html?id=88&Source=Jobsite http://www.Domain2.org/who-we-are/work-for-us/
RedirectMatch 301 ^/vacancies_apply.html?id=88&Source=Jobsite$ http://www.Domain2.org/who-we-are/work-for-us/
Redirect /vacancies_apply.html?id=88&Source=Jobsite  http://www.Domain2.org/who-we-are/work-for-us/
Redirect "/vacancies_apply.html?id=88&Source=Jobsite"  http://www.Domain2.org/who-we-are/work-for-us/
0
 
Dave BaldwinFixer of ProblemsCommented:
See if this will work on these two.  Are you redirecting everything from "vacancies_apply.html" or just the five listed above?

RewriteEngine on
RewriteCond ^vacancies_apply\.html?id=88&Source=Jobsite$ [NC,OR]
RewriteCond ^vacancies_apply\.html?id=88&Source=Reed$ [NC]
RewriteRule ^(.*)$ http://www.domain2.org/who-we-are/work-for-us/ [R=301,L]

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
m-higginsAuthor Commented:
Hi Dave - thanks for the reply I'll try that out...

the regular expression is more the id=88 after "vacancies_apply.html" (as another id may redirect elsewhere..but it will come from different source's

So for now yes it is just these 5.
0
 
m-higginsAuthor Commented:
Grr - it hasn't worked...
0
 
m-higginsAuthor Commented:
I ended up to it via PHP

if (($_SERVER[HTTP_HOST].$_SERVER['REQUEST_URI'] == 'www.domain1.co.uk/vacancies_apply.html?id=88&Source=FFR%20Online') || 
($_SERVER[HTTP_HOST].$_SERVER['REQUEST_URI'] == 'www.domain1.co.uk/vacancies_apply.html?id=88&Source=Jobsite') || 
($_SERVER[HTTP_HOST].$_SERVER['REQUEST_URI'] == 'www.domain1.co.uk/vacancies_apply.html?id=88&Source=Reed') || 
($_SERVER[HTTP_HOST].$_SERVER['REQUEST_URI'] == 'www.domain1.co.uk/vacancies_apply.html?id=88&Source=CV%20Library') || 
($_SERVER[HTTP_HOST].$_SERVER['REQUEST_URI'] == 'www.domain1.co.uk/vacancies_apply.html?id=88&Source=MyJobGroup'))
{
header('Location: http://www.domain2.org/who-we-are/work-for-us/');
}

Open in new window


Not the cleanest I know - but it works and the client is happy.
It was only ever going to be a temp thing.

Thanx anyway Dave
0
 
arober11Commented:
You need to handle the URI independently from the CGI parameters, so something along the following lines should do:

RewriteEngine On

RewriteCond  %{QUERY_STRING}  Source=Word[ ]Space|Source=Jobsite|Source=Reed|Source=Another[ ]Word   [NC]
RewriteCond  %{QUERY_STRING}    id=88&
RewriteRule  /vacancies_apply.html    http://www.Domain2.org/who-we-are/work-for-us/  [L]

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
The PHP method was going to be my next suggestion...  Glad you got it working.
0
 
m-higginsAuthor Commented:
no other solutions where suitable in the timeframe
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now