Solved

htaccess rewrite 301 need help

Posted on 2012-03-27
6
301 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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now