Welcome to WebmasterWorld Guest from 107.20.34.173

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Quick little RewriteCond Problem. Halfway there!

Need some help over here.

     

acimag

5:58 pm on Jul 7, 2011 (gmt 0)

5+ Year Member



the URL in the search engines shows:

[somecompany.org...]
I want it to go to
[somecompany.org...]


RewriteCond %{HTTP_HOST} ^somecompany.org
RewriteCond %{QUERY_STRING} ^p=insurance$
RewriteRule ^index\.htm$ [somecompany.org...] [R=301,L]


I have like 20 pages just like that. Any Ideas? Ive read a bunch of tutorials and can't find one sniplet.

g1smd

6:16 pm on Jul 7, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



That's the redirect for AFTER you have changed the links on the page to point to the new URL. URLs are defined in links. You change a URL by changing the link the user clicks on.

You have the redirect from query string URL to SEF URL in place. Next you need a rewrite to accept SEF requests and rewrite the request to the script to return the content.

Once both are in place you'll find you have an infinite redirect-rewrite loop. Change the RewriteCond in the redirect code to look at THE_REQUEST and not QUERY_STRING. This will ensure you redirect only direct client requests, not previously rewritten pointers.

Use the Live HTTP Headers extension for Firefox to investigate the HTTP transaction between browser and server.

acimag

7:09 pm on Jul 7, 2011 (gmt 0)

5+ Year Member



Yea i have all of the links working and they have double indexed.
I have rewritten the index page so have the right links there and click. However the damage is already done. Some with the ?p= and some with the .html are in google.

So im trying to avoid all of the duplicate content issues.

I even tried:
RewriteBase /
RewriteRule ^?p=insurance$ [somesite.org...] [R=301,NC,L]

g1smd

8:11 pm on Jul 7, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



RewriteRule cannot see query strings, as mentioned above. You need a preceding RewriteCond looking at THE_REQUEST.

Add a question mark to the end of the target URL to stop the query string data being re-appended.

Use example.com in the forum to stop URL auto-linking. [google.com...]

acimag

8:08 pm on Jul 20, 2011 (gmt 0)

5+ Year Member



So proud of myself. I finally figured it out thanks to your THE_REQUEST tip.

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?p=([^&]+)\ HTTP/
RewriteRule ^$ [example[dot]com...] [R=301,L]

Worked like a charm. Any Other tips maybe?

g1smd

10:22 pm on Jul 20, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Yes, make sure that index.php as well as blank is also redirected.

Use
/(index\.php)?\?p
and
^(index\.php)?$


Use example.com in the forum to stop URL auto-linking.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month