iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
IT Discussion Forum Having IT issues? Got IT questions? Who doesn't? If you can't get your Apache to work with your MySQL or your php is choking on your ODBC... Let's see if we can help you come up with some ideas.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-13-2008, 07:50 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Hi all. One of my webpages has been hijacked, and of course as always
google has rewarded the hijacker by REMOVING my top ranked 10
year old URL from their index and then ADDING the bogus URL in
their index, which shows for no searches! The URL now has a
strange thing appended to the rear: ?ref=pislikcs.com

I have been trying to do a 301 redirect from that URL to the
REAL URL, but I can't! I've tried through cPanel's URL
Redirect area and it won't work. It won't even get added! I
then tried manually adding it in my htaccess file, but it still
won't work! So obviously the "?" is screwing up something, so
can anyone please tell me how I redirect:

domain.com/page.html?ref=pislikcs.com

TO:

domain.com/page.html

Thanks,
-Clint
__________________
God Bless
-Clint
Reply With Quote
  #2 (permalink)  
Old 10-13-2008, 03:36 PM
crankydave's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Aug 2004
Location: Playing with fire!
Posts: 4,120
crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

I came across the same issue. What worked for me was {QUERY_STRING}

In your example I "think" something like...

RewriteCond %{QUERY_STRING} ref=pislikcs.com
RewriteRule \page.html http://www.domain.com/page.html? [R=301,L]

...might work. Perhaps one of the better coders can help out on this.

Dave
Reply With Quote
  #3 (permalink)  
Old 10-13-2008, 04:52 PM
da8iwr's Avatar
WebProWorld New Member
 
Join Date: Sep 2005
Location: North East UK
Posts: 11
da8iwr RepRank 0
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

If you use the HTAccess file,to do this, it will work perfectly

Quote:
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html http://www.yoursite.com/folder/
If you search on google for "HTAccess 301 redirect" there is tons of stuff mate.
Reply With Quote
  #4 (permalink)  
Old 10-13-2008, 05:37 PM
crankydave's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Aug 2004
Location: Playing with fire!
Posts: 4,120
crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

No it won't da8iwr... not with dynamic URL's on Apache. Simple redirects won't work. Additionally, case sensitivity must be taken into consideration.

Dave
Reply With Quote
  #5 (permalink)  
Old 10-13-2008, 06:29 PM
da8iwr's Avatar
WebProWorld New Member
 
Join Date: Sep 2005
Location: North East UK
Posts: 11
da8iwr RepRank 0
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Yes it will, i had a Joomla site on a domain name until a few weeks ago, when i changed its domain name, and needed to redirect the urls to the new site, so if anybody found the products in google, it would be redirected, so i made this htaccess file.



HTML Code:
redirect 301 /vr.html http://www.mysite.co.uk/index.php/ice-sculptures/ice-sculpture-movies
redirect 301 /testimonial.html http://www.mysite.co.uk/index.php/testimonials
redirect 301 /vr-elephant.html http://www.mysite.co.uk/index.php/ice-sculptures
redirect 301 /contact.html http://www.mysite.co.uk/index.php/contact-us
redirect 301 /nicolewedding.html http://www.mysite.co.uk/index.php/testimonials/ice-wedding-cake
redirect 301 /vr-fish.html http://www.mysite.co.uk/index.php/ice-sculpture-movies/1-sculptures/20-ice-fish-sculpture
redirect 301 /vr-elephant.html http://www.mysite.co.uk/index.php/ice-sculpture-movies/1-sculptures/19-ice-elephant-movie
redirect 301 /clients.html http://www.mysite.co.uk/index.php/our-clients
redirect 301 /products.asp http://www.mysite.co.uk/index.php/gallery
redirect 301 /sub.asp http://www.mysite.co.uk/index.php/gallery

You could also do this with none sef urls, so you just need to know what the url is it is trying to pick up, for example

HTML Code:
redirect 301 //index.php?option=com_virtuemart&page=shop.browse&category_id=2&Itemid=3 http://www.google.co.uk
would work perfectly ok.

Last edited by da8iwr; 10-13-2008 at 06:38 PM.
Reply With Quote
  #6 (permalink)  
Old 10-13-2008, 06:41 PM
da8iwr's Avatar
WebProWorld New Member
 
Join Date: Sep 2005
Location: North East UK
Posts: 11
da8iwr RepRank 0
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Sorry Clint1, just realised you put the URLs you want to change from and to.

HTML Code:
redirect 301 domain.com/page.html?ref=pislikcs.com domain.com/page.html
That should work perfectly OK.
Reply With Quote
  #7 (permalink)  
Old 10-13-2008, 08:13 PM
SEO's Avatar
SEO SEO is offline
WebProWorld Pro
 
Join Date: Apr 2008
Posts: 160
SEO RepRank 1
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Try adding this code to your header:

<script type="text/javascript">
if(top!= self) top.location.href = self.location.href
</script>


More information about Hijacking below:

Quote:
Originally Posted by SEO View Post
I had a website hijacked a few years ago (2 websites actually)...

One of them displayed my site within a frame on their site and displayed their Google Adsense code above all of my pages. A code very similar to the one posted above helped me with that problem (although by the time I figured it out it was too late, the damage had been done).

I also had somebody else doing a 302 meta refresh to one of my websites.

I found some helpful information on these pages:
Stop 302 Redirects and Scrapers from Hijacking Web Page PR - Page Rank
How to Find a Hijacker using 302 Redirects and Report Them
How to Report a 302 Redirect or Web Page Hijackings and Scapers
How to Stop Content Theft
How to Find a Scraper Directory and Report them to Google

For a "break out of frames script" look here:
I Hate Frames

Or here is a good one:
<script type="text/javascript">
if(top!= self) top.location.href = self.location.href
</script>

I hope this helps... I know how disheartening it can be when some mongrel hijacks your website.
Reply With Quote
  #8 (permalink)  
Old 10-13-2008, 11:14 PM
edhan's Avatar
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Singapore
Posts: 652
edhan RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

My personal opinion will be finding out the source of the problem and rectify it instead of using redirect. This will be a permanent solution.

If you have done a backup of your website, simply delete the entire site and re-install it again. At the same time, you must try to find out where is the security breach so you can plug the hole otherwise it will happen again and again.
Reply With Quote
  #9 (permalink)  
Old 10-14-2008, 09:15 AM
crankydave's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Aug 2004
Location: Playing with fire!
Posts: 4,120
crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

da8iwr... Simple redirects fail as soon as the question mark is added.

Dave
Reply With Quote
  #10 (permalink)  
Old 10-14-2008, 09:34 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,376
wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

As far as I can tell, the only way to do this reliably is with mod_rewrite, as Dave showed above. I would just alter that code slightly so that it should work for any page on your site. I think the following should work:

Code:
RewriteCond %{QUERY_STRING} ref=pislikcs.com 
RewriteRule ^(.*).html$ http://example.com/%1.html [R=301,L]


This should take the entire URL up to the .html extension and replace it in a redirect without a query string. The rewriteCond directive should ensure this is only done for ref=pislikcs.com so that other query strings on your site will still work.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #11 (permalink)  
Old 10-14-2008, 12:52 PM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Guys, thanks for all the replies. I'll read over all this and try them.
__________________
God Bless
-Clint
Reply With Quote
  #12 (permalink)  
Old 10-15-2008, 03:10 PM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,376
wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Ok, I have come to realize that the code I gave won't work for the root page of a folder (ie domain.tld/). The following code should work in all cases:

Code:
RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #13 (permalink)  
Old 10-15-2008, 03:24 PM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by wige View Post
Ok, I have come to realize that the code I gave won't work for the root page of a folder (ie domain.tld/). The following code should work in all cases:

Code:
RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
Thanks for trying, but that doesn't work. I had a few minutes spare so I tried it. This is what the resulting page is: http://www.domain.com/page_name.html/page_name.html
As you can see, the page name is duplicated! It puts a slash on the end, the duplicates the page name. I tried both of these:

RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) http://www.domain.com/page_name.html/$1? [R=301,L]

AND:

RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) /page_name.html/$1? [R=301,L]

And I also tried removing the / after "html".

BTW, there's a question mark you left out, I don't know if that matters. The invalid bad appending data is ?ref=pislikcs.com
__________________
God Bless
-Clint
Reply With Quote
  #14 (permalink)  
Old 10-15-2008, 03:34 PM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,376
wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

The question mark should be removed from the first line, as the QUERY_STRING variable only contains what is after the question mark.

If the first one is causing duplication, I would check what other rewrite rules you have enabled, because what may be happening is that two conflicting rewrites are happening. Make sure those two lines are the first thing in the .htaccess file, after any RewriteEngine on directive. The L at the end will ensure that no other rewrites are processed after it.

EDIT: I see what the problem is. The first version has the page name stated explicitly. Change the first one from this:

RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) http://www.domain.com/page_name.html/$1? [R=301,L]

to this:

RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) http://www.domain.com/$1? [R=301,L]

(removing the bolded part)
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog

Last edited by wige; 10-15-2008 at 03:36 PM.
Reply With Quote
  #15 (permalink)  
Old 10-23-2008, 10:14 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Nice to see this site back up! What's been going on, every time I'd come here to try and read the replies the site was down. So I'll be trying these methods today and report back. Thanks again guys.

"Edhan", as you may know, G refuses to tell you from where IBL's originate for an inside URL. I searched for the bogus URL in G and found nothing (other than of course the bogus URL). But in Y's Site Explorer I could at least see who's linking to the URL, but not a single one was using the bogus URL, all of the IBL's to that page were legit using the correct URL.
__________________
God Bless
-Clint
Reply With Quote
  #16 (permalink)  
Old 10-23-2008, 10:41 AM
edhan's Avatar
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Singapore
Posts: 652
edhan RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Yes. I am having problems with this site at times. Seems like it is getting 'hot' as I can't login at times.

Well, as I have said, I like to settle the source of the problem. Since you can't find out where is the root of the problem, you can only resolve using redirect 301. This may happen again with other url link but then you have no choice but resort to redirect until you can find the source of the problem.
Reply With Quote
  #17 (permalink)  
Old 10-25-2008, 08:50 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Exclamation Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Dave, thanks but this below ruined the page! Now this is urgent. I even removed it from the htaccess file and the page is still totally blank! But the source code is still there! Yes, my cache is totally cleared when I close IE, so why is the page still blank after removing the code from my htaccess file??

Quote:
Originally Posted by crankydave View Post
I came across the same issue. What worked for me was {QUERY_STRING}

In your example I "think" something like...

RewriteCond %{QUERY_STRING} ref=pislikcs.com
RewriteRule \page.html http://www.domain.com/page.html? [R=301,L]

...might work. Perhaps one of the better coders can help out on this.

Dave
__________________
God Bless
-Clint
Reply With Quote
  #18 (permalink)  
Old 10-25-2008, 09:07 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Ok I see what the problem was, I tried this code below around the same time and it didn't work, and when I removed it I obviously removed part of some JS that was needed in the head tag.

Quote:
Originally Posted by SEO View Post
Try adding this code to your header:

<script type="text/javascript">
if(top!= self) top.location.href = self.location.href
</script>
Thanks but that didn't do anything.
__________________
God Bless
-Clint
Reply With Quote
  #19 (permalink)  
Old 10-25-2008, 09:09 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by crankydave View Post
I came across the same issue. What worked for me was {QUERY_STRING}

In your example I "think" something like...

RewriteCond %{QUERY_STRING} ref=pislikcs.com
RewriteRule \page.html http://www.domain.com/page.html? [R=301,L]

...might work. Perhaps one of the better coders can help out on this.

Dave
Ok now that I've got the blank page issue fixed , this suggestion above didn't work Dave. How exactly did you get it to work for you?
Thanks.
__________________
God Bless
-Clint
Reply With Quote
  #20 (permalink)  
Old 10-25-2008, 09:28 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by da8iwr View Post
Sorry Clint1, just realised you put the URLs you want to change from and to.

HTML Code:
redirect 301 domain.com/page.html?ref=pislikcs.com domain.com/page.html
That should work perfectly OK.
Thanks but that too doesn't work. I tried it exactly like that, without any http: //www. prefix, and I tried it with the the prefix, as well as without any root noted, just the /page.html. (One method caused the entire website to give the "Internal Error" where no pages were accessible). Wouldn't that method require some kind of RewriteCond %{QUERY_STRING} line?

WTF?? I had to edit that, http: //www. without the space showed as "Hiring Center | Powered by Monster.com"!!!!
__________________
God Bless
-Clint

Last edited by Clint1; 10-25-2008 at 09:31 AM.
Reply With Quote
  #21 (permalink)  
Old 10-25-2008, 09:43 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by edhan View Post
Yes. I am having problems with this site at times. Seems like it is getting 'hot' as I can't login at times.

Well, as I have said, I like to settle the source of the problem. Since you can't find out where is the root of the problem, you can only resolve using redirect 301. This may happen again with other url link but then you have no choice but resort to redirect until you can find the source of the problem.
Exactly, that's why I'm having to ask about the redirect.
__________________
God Bless
-Clint
Reply With Quote
  #22 (permalink)  
Old 10-25-2008, 09:58 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by wige View Post
The question mark should be removed from the first line, as the QUERY_STRING variable only contains what is after the question mark.

If the first one is causing duplication, I would check what other rewrite rules you have enabled, because what may be happening is that two conflicting rewrites are happening. Make sure those two lines are the first thing in the .htaccess file, after any RewriteEngine on directive. The L at the end will ensure that no other rewrites are processed after it.

EDIT: I see what the problem is. The first version has the page name stated explicitly. Change the first one from this:

RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) http://www.domain.com/page_name.html/$1? [R=301,L]

to this:

RewriteCond %{query_string} ref=pislikcs.com
RewriteRule (.*) http://www.domain.com/$1? [R=301,L]

(removing the bolded part)
Thanks again, but I'm sorry to say that too did not work.

Now regarding what could be causing these suggestions NOT to work:

I have "Hot Link Protection" enabled, and these redirects:

---------------------
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html
RewriteRule ^index\.html$ http://www.domain.com/ [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]

-----------------------

That first one is because (guess who) was hitting on my homepage and putting an "index.html" page on it and calling it duplicate content! So I was forced to create that redirect thanks again to G. The second is just a non-www to www version redirect. Then these:

---------------------
Options +FollowSymLinks
Options +SymlinksIfOwnerMatch

RewriteBase /
RewriteRule ^pc-cillin/(.*)
http://www. trendmicro .com/vinfo/virusencyclo/default.asp

Options +FollowSymLinks
Options +SymlinksIfOwnerMatch

RewriteBase /
RewriteRule ^vinfo/(.*)
http://www. trendmicro .com/vinfo/virusencyclo/default.asp

----------------------------------

I had to create those because (once again, GUESS WHO!) was putting MY domain as the Trend Micro domain on numerous Trend Micro SUB-pages when the Gbot would spider my virus info pages which have a feed on them from Trend.

Then I have few redirects for old URL's done via cPanel to new URL's that are similar to this:

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^OldPage.html$ "http\:\/\/www\.domain\.com\/New_Page\.html" [R=301,L]


Now that may be the problem because that is the URL that's been affected by this ?ref=pislikcs.com problem! Now if that is the cause, then how can that redirect be Incorporated into the new one I now need?

I also have some IP Deny's listed in the htaccess file, but I'm sure that wouldn't affect anything. Also, should the "RewriteEngine on" be at the VERY TOP of the htaccess file, or does it matter? It used to be right before the redirects began in the file, but recently "it moved" for some reason to the very top ABOVE the IP's listed for the IP Deny area. I have since put it back below the "IP Deny" IP's listed and right before the first redirect.
Thanks.

EDIT: I HATE the way this website screws up URL's and creates text links for them! So this time I had to go and put spaces in the Trend Micro URL's so they could be seen!
__________________
God Bless
-Clint

Last edited by Clint1; 10-25-2008 at 10:00 AM. Reason: noted
Reply With Quote
  #23 (permalink)  
Old 10-25-2008, 10:17 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

BTW, I did try using one of the existing cPanel redirects to change the HTTP_HOST to QUERY_STRING and that didn't work.
__________________
God Bless
-Clint
Reply With Quote
  #24 (permalink)  
Old 10-28-2008, 03:38 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Anyone still on this thread?
__________________
God Bless
-Clint
Reply With Quote
  #25 (permalink)  
Old 10-28-2008, 08:10 AM
crankydave's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Aug 2004
Location: Playing with fire!
Posts: 4,120
crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by Clint1 View Post
Anyone still on this thread?
Yep... still here.

I'll copy the first few lines that I'm using that is working just fine for me.

Dave
Reply With Quote
  #26 (permalink)  
Old 10-28-2008, 09:18 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,376
wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5wige RepRank 5
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

This ruleset:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^OldPage.html$ "http\:\/\/www\.domain\.com\/New_Page\.html" [R=301,L]

is not needed and can be replaced with something more effective that requires less overhead:
Redirect 301 oldpage.html http://www.domain.tld/New_Page.html

Generally, I try to avoid the use of mod_rewrite except where I am doing internal rewrites. Because of the pattern recognition components of the mod_rewrite system, each rule adds significant overhead to the server software which results in a slight reduction in performance - although slight it can add up. Also, most webmasters are not overly familiar with regular expressions, and unexpected conflicts can occur between mod_rewrite rulesets as a result.

The RewriteEngine on directive needs to be before the first RewriteCond or Rewrite Rule directive. Beyond that, it's placement should not matter.

If you want, send me a copy of your .htaccess file in PM and I can take a look, see if I can spot where the conflict might be.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog

Last edited by wige; 10-28-2008 at 09:22 AM.
Reply With Quote
  #27 (permalink)  
Old 10-28-2008, 01:40 PM
crankydave's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Aug 2004
Location: Playing with fire!
Posts: 4,120
crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6crankydave RepRank 6
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by wige View Post

The RewriteEngine on directive needs to be before the first RewriteCond or Rewrite Rule directive. Beyond that, it's placement should not matter.
At least one exception would be numbers. Example, if you're redirecting a URL's with say category=10, category=100, category=1000, etc. They have to be listed from highest number to lowest. If not, the redirect stops at the first partial match it finds.

Clint... Here's the first few lines I'm using and it works fine...

Code:
RewriteEngine on

RewriteCond %{QUERY_STRING} Category=210
RewriteRule Category\.asp http://www.chainzonline.com/saint-monica-medals.html? [R=301,L]

RewriteCond %{QUERY_STRING} Category=209
RewriteRule Category\.asp http://www.chainzonline.com/saint-miguel.html? [R=301,L]
Dave
Reply With Quote
  #28 (permalink)  
Old 10-29-2008, 09:49 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Dave, where's the old URL and new URL in your code? Or is both of those areas one redirect and both URL's (old and new) have the ? in them?
__________________
God Bless
-Clint
Reply With Quote
  #29 (permalink)  
Old 10-29-2008, 09:59 AM
WebProWorld Veteran
 
Join Date: Jun 2005
Location: Louisiana, USA
Posts: 775
Clint1 RepRank 2
Default Re: How do you 301 redirect a dynamic URL (URL with a question mark in it)?

Quote:
Originally Posted by wige View Post
This ruleset:
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^OldPage.html$ "http\:\/\/www\.domain\.com\/New_Page\.html" [R=301,L]

is not needed and can be replaced with something more effective that requires less overhead:
Redirect 301 oldpage.html http://www.domain.tld/New_Page.html

Generally, I try to avoid the use of mod_rewrite except where I am doing internal rewrites. Because of the pattern recognition components of the mod_rewrite system, each rule adds significant overhead to the server software which results in a slight reduction in performance - although slight it can add up. Also, most webmasters are not overly familiar with regular expressions, and unexpected conflicts can occur between mod_rewrite rulesets as a result.
Thanks Wige, that worked but it requires a slash for it to work for me:
Redirect 301 /oldpage.html http://www.domain.tld/New_Page.html

That's just the way cPanel does the redirects, but if you think that method is better than theirs, then I'll change all of mine to that method. Thanks.


Quote:
The RewriteEngine on directive needs to be before the first RewriteCond or Rewrite Rule directive. Beyond that, it's placement should not matter.
Ok thank you (and I saw your note on that statement Dave).

Quote:
If you want, send me a copy of your .htaccess file in PM and I can take a look, see if I can spot where the conflict might be.
That's in that long post above of mine, I pasted it into the post #22, everything in bold, plus the Hot Link Protection data from cPanel is also in the file.
__________________
God Bless
-Clint

Last edited by Clint1; 10-29-2008 at 10:01 AM.
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > IT Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP dynamic 301 redirect based on Product ID rumblepup Web Programming Discussion Forum 11 04-28-2007 07:38 AM
301 Redirect on dynamic site netfrugal Search Engine Optimization Forum 1 10-03-2006 08:05 PM
301 redirect for dynamic site b2bseo Google Discussion Forum 0 09-09-2005 02:45 AM
Dynamic URL question curtbro Search Engine Optimization Forum 3 01-24-2005 06:31 PM
newbie question on dynamic pages ralf_the_cat Web Programming Discussion Forum 2 11-24-2003 01:10 PM


All times are GMT -4. The time now is 09:53 AM.



Search Engine Optimization by vBSEO 3.3.0