Solved

htaccess rewrite 301 need help

Posted on 2012-03-27
6
309 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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

785 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