Solved

htaccess rewrite 301 need help

Posted on 2012-03-27
6
318 Views
Last Modified: 2012-03-28
my old url is - http://www.mysite.com/search.php?search=tape

Then at /htaccess I - "Redirect 301 /search.php http://www.mysite.com/dictionary"

I then rewrite again in /dictionary - "RewriteRule ^word/(.*) dictionary/index.php?search=$1"

Result: http://www.mysite.com/dictionary/?search=tape

I am trying to get the URL as - "http://www.mysite.com/dictionary/word/tape"

Now the rewrite at the /dictionary does work, if I manually type in a URL like "http://www.mysite.com/dictionary/word/tape" it works. But from the redirects that come in it does not.

I hope this makes sense, because I have confused myself :)
0
Comment
Question by:cbielich
  • 3
  • 2
6 Comments
 
LVL 1

Author Comment

by:cbielich
ID: 37772793
anyone?
0
 
LVL 15

Expert Comment

by:babuno5
ID: 37775155
my self also confused as to what you want to achieve

Can you post what is there in your .htaccess as is ?


And what i understand is you want the following url  

http://www.mysite.com/search.php?search=tape

to go to

http://www.mysite.com/dictionary/word/tape
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 37775170
I got the same impression as babuno5.  To implement that, try this:

RewriteCond %{QUERY_STRING} search=([a-zA-Z]+) [NC]
RewriteRule ^/?search.php$ /dictionary/word/%1 [R=301,NC]

Open in new window

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 1

Author Comment

by:cbielich
ID: 37777243
Babuno5 - Yes that is exactly what I am trying to do

rountinet - my result URL is "http://www.mysite.com/dictionary/word/tape?search=tape"

close :)
0
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 37778371
End the rule with a '?':

RewriteCond %{QUERY_STRING} search=([a-zA-Z]+) [NC]
RewriteRule ^/?search.php$ /dictionary/word/%1? [R=301,NC]

Open in new window

0
 
LVL 1

Author Closing Comment

by:cbielich
ID: 37778903
Thats it thanks :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

713 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