473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Redirect with .htaccess

I am trying to fix a problem where Google has indexed the wrong version of a
URL. I need to redirect the bad version to the good version with 301
redirects.

I've tried a couple of things, but it's not working.

The bad URLs look like this:
/search.php?mode=search&narrow_cat=2&term=World,%20 Hello&page=1

That should redirect to:
/dir/Hello_World

This one doesn't work at all:
RewriteRule
^search\.php\?mode=search&narrow_cat=[0-9]{1,2}&term=([A-Z]{1}[a-z]+),%20([A-Z]{1}[a-z]+)&page=1$
http://www.example.com/dir/$2_$1 [R=301,NC,L]
This one works, except it doesn't include the "Hello" and the "World", only
the underscore:

RewriteCond %{QUERY_STRING}
mode=search&narrow_cat=[0-9]{1,2}&term=([A-Z]{1}[a-z]+),%20([A-Z]{1}[a-z]+)&page=1$
RewriteRule ^search\.php http://www.example.com/dir/$2_$1 [R=301,NC,L]

Any ideas?
Nov 28 '06 #1
2 1155
"mobile_1" <mo******@nospam.invalidwrote in message
news:12*************@corp.supernews.com...
>I am trying to fix a problem where Google has indexed the wrong version of
a URL. I need to redirect the bad version to the good version with 301
redirects.
Just use a robots.txt to tell googlebot not to index the wrong page. And
also go ask the Apache questions in an apache group, this is c.l.php...

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net | rot13(xv***@bhgbyrzcv.arg)
Nov 29 '06 #2
"Kimmo Laine" <sp**@outolempi.netwrote in message
news:lJ*******************@reader1.news.jippii.net ...
"mobile_1" <mo******@nospam.invalidwrote in message
news:12*************@corp.supernews.com...
>>I am trying to fix a problem where Google has indexed the wrong version of
a URL. I need to redirect the bad version to the good version with 301
redirects.

Just use a robots.txt to tell googlebot not to index the wrong page. And
also go ask the Apache questions in an apache group, this is c.l.php...
Sorry, I didn't know about the Apache group.

Robots.txt isn't as good as a redirect since it abandons the PageRank of the
indexed versions.

I found an answer: use %1 and %2 instead of $1 and $2.

Dec 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: | last post by:
This is an apache question (little off-topic) I have this .htaccess in web root -------------- ErrorDocument 404 /error404handler.php -------------- BUT I take in Mozilla this when I call a...
2
by: Sean Pinto | last post by:
My hosting company has an automatic redirect page called /missing/missing.php and I want to log all of the page not founds that result in a redirection to missing.php. I can't seem to find out how...
7
by: Tim Evans | last post by:
I'm using a meta-refresh construct to redirect a URL: <meta http-equiv="REFRESH" content="0;url=http://path/to/new/url"> I would like to be able to make this open in a new window, rather than...
3
by: Vardan Kushnir | last post by:
Please forgive me if my English is poor. Also please tell me if this is wrong place to ask this question and tell me better place. When searching web for information Re: .htaccess and...
5
by: deko | last post by:
I'm trying to redirect requests for /index.php to /mydirectory/index.php If I use an index file in / with only this line: <?php header("Location:http://www.mysite.com/mydirectory/"); ?> that...
0
by: Stuart Palmer | last post by:
Hi everyone, I'm trying to look for an asp equivilent of .htaccess that is used on apache servers but for use with asp. I am doing a website and moving lots of files into a single directory to...
2
by: =?ISO-8859-1?Q?Fran=E7ois_de_Dardel?= | last post by:
I am not sure if this is the proper forum, but I always found very helpful information here and I would like to have the advice of experts. Just before new year (end Dec 2006), my internet...
8
by: howa | last post by:
a page currently in HTTPS, I force the client to redirect to another page using HTTP under the same domain (e.g. abc.com), i.e. header("Location: http://www.abc.com/index.php"); IE...
2
by: RuthC | last post by:
Hi. I am using .htaccess to redirect in my website Now I want to redirect a url, which Contain '-' to another url. ex: RewriteRule ^book-and-magazine-discount/ query.php?q=$1.
2
by: RuthC | last post by:
Hi, In my website there is a facility for user to create there own pages we are maintaing this url as www.mywebsite.com/mypage/user created page name ex : www.mywebsite.com/mypage/ruth user...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.