Google Answers Logo
View Question
 
Q: Apache htaccess rewriterule problem ( No Answer,   5 Comments )
Question  
Subject: Apache htaccess rewriterule problem
Category: Computers > Programming
Asked by: anotherdumbass-ga
List Price: $40.00
Posted: 03 Sep 2006 12:52 PDT
Expires: 03 Oct 2006 12:52 PDT
Question ID: 761906
Hello Google,

We have re-written a URL to a different URL, via .htaccess Rewriterule as follows:

Original URL:
http://yoursite.com/XXXX_Search/SEARCHTERM

Rewrote to:
http://yoursite.com/page/BBBB/SRCHM/SearchOptions/11011111001011/HF/1/AddOptions/3|10|11|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|36|37|40|41|42|43|44|45|46|47|48|49|66|68|70|74|75|85|86|87|89|99|100|101|102|103|104|105|106|107|128|129|131|132|148|149|150|151/Search_Search/SEARCHTERM

The above rewrite was achieved using the following Rewriterule in
.htaccess, and all works well:

RewriteRule ^XXXX_Search/(.*)$
/page/BBBB/SRCHM/SearchOptions/11011111001011/HF/1/AddOptions/3|10|11|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|36|37|40|41|42|43|44|45|46|47|48|49|66|68|70|74|75|85|86|87|89|99|100|101|102|103|104|105|106|107|128|129|131|132|148|149|150|151/Search_Search/$1
[NC,L]

Now, we're currently trying to round up all the old links on search
engines that use the long clumsy URL and 301 redirect them to the new
smaller URL, but we're having difficulties, we just can't get the new
rewrite to take hold. I have a feeling that the order of the rewrites
in the .htaccess is hindering us also...

Here is our .htaccess:

RewriteEngine On
RewriteBase /

RewriteRule ^(.*)/Search_Search/(.*)$ XXXX_Search/$2 [R=301,NC,L]
#<--- this is our attempt, we can't get to function properly

RewriteRule ^XXXX_Search/(.*)$
/page/BBBB/SRCHM/SearchOptions/11011111001011/HF/1/AddOptions/3|10|11|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|36|37|40|41|42|43|44|45|46|47|48|49|66|68|70|74|75|85|86|87|89|99|100|101|102|103|104|105|106|107|128|129|131|132|148|149|150|151/Search_Search/$1
[NC,L]

Any insight you have is appreciated!

Clarification of Question by anotherdumbass-ga on 10 Sep 2006 17:02 PDT
Yes, exactly. Our search utility functions with the long URL's in the
background, but we want the short URL's shown to visitors and/or
listed on search engines.

Sorry I waited so long for this feedback, I have been waiting to be
notified by email, which never happened.
 
Let me be more clear... we are trying to show links on our website,
using only the short URL's, in the past we had only the long URL links
listed on our site.

AND

We are also trying to 301 redirect all long clumsy URL's that remain
on search engines to the short URL, to hopefully help our site rank,
as they are duplicate pages.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Apache htaccess rewriterule problem
From: iscorpio-ga on 05 Sep 2006 02:42 PDT
 
LINE 1: RewriteRule ^(.*)/Search_Search/(.*)$ XXXX_Search/$2 [R=301,NC,L]
LINE 2: RewriteRule ^XXXX_Search/(.*)$ /page/BB4|9...51/Search_Search/$1 [NC,L]
------------------
there is a problem, when the script get the long clumsy URL request or
301 error, it will be redirect to LINE 2, but when it enter the LINE
2, it will been redirected to the LINE 1 again, so there is a dead
cycle.

do you want to show a short URL to the visitor, but keep the old script structure?
Subject: Re: Apache htaccess rewriterule problem
From: anotherdumbass-ga on 07 Sep 2006 18:56 PDT
 
Yes, exactly. Our search utility functions with the long URL's in the
background, but we want the short URL's shown to visitors and/or
listed on search engines.

Sorry I waited so long for this feedback, I have been waiting to be
notified by email, which never happened.
Subject: Re: Apache htaccess rewriterule problem
From: anotherdumbass-ga on 07 Sep 2006 20:32 PDT
 
Let me be more clear... we are trying to show links on our website,
using only the short URL's, in the past we had only the long URL links
listed on our site.

AND

We are also trying to 301 redirect all long clumsy URL's that remain
on search engines to the short URL, to hopefully help our site rank,
as they are duplicate pages.
Subject: Re: Apache htaccess rewriterule problem
From: htaccesselite-ga on 01 Nov 2006 04:29 PST
 
Try this out!

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^XXXX_Search/.*
RewriteRule ^.+/Search_Search/(.*)$ XXXX_Search/$1 [R=301,NC,L]

RewriteRule ^XXXX_Search/(.*)$
/page/BBBB/SRCHM/SearchOptions/11011111001011/HF/1/AddOptions/3|10|11|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|36|37|40|41|42|43|44|45|46|47|48|49|66|68|70|74|75|85|86|87|89|99|100|101|102|103|104|105|106|107|128|129|131|132|148|149|150|151/Search_Search/$1
[NC,L,QSA]

http://www.htaccesselite.com/htaccess/rewritecond-vt64.html
Subject: Re: Apache htaccess rewriterule problem
From: tsliwowicz-ga on 29 Nov 2006 08:09 PST
 
When using the R directive you need to use the full URL.

So
change-
RewriteRule ^(.*)/Search_Search/(.*)$ XXXX_Search/$2 [R=301,NC,L]
To-
RewriteRule ^(.*)/Search_Search/(.*)$
http://yoursite.com/XXXX_Search/$2 [R=301,NC,L]

Hope this helps.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy