Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

htaccess 301 redirect not working

Posted on 2013-05-16
7
Medium Priority
?
373 Views
Last Modified: 2013-05-17
Hi all :)

i have a page available at 2 URLs:

http://www.futureharvesteurope.com/index.php?mod=prod&p=55
and
http://www.futureharvesteurope.com/index.php?mod=prod&desc=Ozone-plug-in&p=55

i need to redirect the first url to the second one that has the keywords in it. (Ozone-plug-in)

this is my full htaccess that is not doing the job:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RedirectMatch 301 http://www.futureharvesteurope.com/index.php?mod=prod&p=55 http://www.futureharvesteurope.com/index.php?mod=prod&desc=Ozone-plug-in&p=55

RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
RewriteCond %{http_host} ^futureharvesteurope.com$ [nc]
RewriteRule ^(.*)$ http://www.futureharvesteurope.com/$1 [r=301,nc,L] 

Open in new window

0
Comment
Question by:helpchrisplz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 12

Expert Comment

by:Richard Davis
ID: 39171662
First thing I would check is that you have the mod_rewrite module loading in apache.

Next, check your .htaccess file's owner/group and permissions. I am not 100% certain on this, but I believe that the file has to be owned/grouped to the same thing as the apache service and the permissions I think need to be 0700 or 0755.

~AB
0
 
LVL 82

Expert Comment

by:hielo
ID: 39171726
try:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING}     ^(mod=[^&]*&p=[^&]*)$    [OR,NC]
RewriteCond %{QUERY_STRING}     ^(p=[^&]*&mod=[^&]*)$    [NC]
RewriteRule ^/?index.php$       /index.php?%1&desc=Ozone-plug-in      [NC,L,R=301]

Open in new window

0
 
LVL 1

Author Comment

by:helpchrisplz
ID: 39171921
yes that seems to work. I have been looking at it and trying to figure out how to adapt it to other pages i need redirecting like:

http://www.futureharvesteurope.com/index.php?mod=prod&desc=&p=5

to

http://www.futureharvesteurope.com/index.php?mod=prod&desc=ph-monitor-ph-tester&p=5

is there a way that i can say if url has p=5 then redirect to: desc=ph-monitor-ph-tester&p=5

its just that i can't see a way of reusing the code.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 82

Expert Comment

by:hielo
ID: 39172088
>>is there a way that i can say if url has p=5 then redirect to: desc=ph-monitor-ph-tester&p=5
try:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING}     (.*\bp=5\b.*)    [NC]
RewriteRule ^/?index.php$       /index.php?%1&desc=ph-monitor-ph-tester      [NC,L,R=301]

RewriteCond %{QUERY_STRING}     ^(mod=[^&]*&p=[^&]*)$    [OR,NC]
RewriteCond %{QUERY_STRING}     ^(p=[^&]*&mod=[^&]*)$    [NC]
RewriteRule ^/?index.php$       /index.php?%1&desc=Ozone-plug-in      [NC,L,R=301]
0
 
LVL 1

Author Comment

by:helpchrisplz
ID: 39174230
i used that code but when going to:
http://www.futureharvesteurope.com/index.php?mod=prod&desc=&p=5

The url changes to this:
http://www.futureharvesteurope.com/index.php?mod=prod&desc=&p=5&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester&desc=ph-monitor-ph-tester

using:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /


RewriteCond %{QUERY_STRING}     (.*\bp=5\b.*)    [NC]
RewriteRule ^/?index.php$       /index.php?%1&desc=ph-monitor-ph-tester      [NC,L,R=301]

RewriteCond %{QUERY_STRING}     ^(mod=[^&]*&p=[^&]*)$    [OR,NC]
RewriteCond %{QUERY_STRING}     ^(p=[^&]*&mod=[^&]*)$    [NC]
RewriteRule ^/?index.php$       /index.php?%1&desc=Ozone-plug-in      [NC,L,R=301]


RewriteCond %{THE_REQUEST} ^.*\/index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
RewriteCond %{http_host} ^futureharvesteurope.com$ [nc]
RewriteRule ^(.*)$ http://www.futureharvesteurope.com/$1 [r=301,nc,L] 

Open in new window


It must 301 it then see it has the p=5 and redo it again and again?
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 39174973
>>It must 301 it then see it has the p=5 and redo it again and again?
agree. Try:
RewriteCond %{QUERY_STRING}     (.*\bp=5\b.*)    [NC]
RewriteCond %{QUERY_STRING}    !(desc=ph-monitor-ph-tester)     [NC]
RewriteRule ^/?index.php$       /index.php?%1&desc=ph-monitor-ph-tester      [NC,L,R=301]
0
 
LVL 1

Author Closing Comment

by:helpchrisplz
ID: 39175038
Thanks you own.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question