StatCounter User Forum  
StatCounter Free web tracker and counter

Go Back   StatCounter User Forum > Webmaster > Lounge (non-StatCounter related topics here!)

Reply
 
Thread Tools Display Modes
  #1  
Old 08-31-2007, 09:04 PM
-=Seth=- -=Seth=- is offline
Active Member
 
Join Date: Nov 2006
Location: lost in space
Posts: 516
Default htaccess coding help

This is a 301 redirect i was trying to do in my htaccess file, unfortunately it doesnt work and i cant figure out why

Quote:
Redirect 301 /index.php?act=viewCat&catId=75 http://www.grooming-health.com/proraso.htm
Redirect 301 /index.php?act=viewCat&catId=84 http://www.grooming-health.com/dovo-solingen.htm
can anybody see what i'm doing wrong, thanks
Reply With Quote
  #2  
Old 08-31-2007, 09:16 PM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,145
Default

It's because of the query string.

You need the mod rewrite module.
You need to test the query string and redirect that way.

Can't test it now though, I need to be at home.

Try thsi:

Quote:
Options +Indexes +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^act=viewCat&catId=75 [nc]
RewriteRule ^(.*)$ http://www.grooming-health.com/proraso.htm [L,R=301]

RewriteCond %{QUERY_STRING} ^act=viewCat&catId=85 [nc]
RewriteRule ^(.*)$ http://www.grooming-health.com/dovo-solingen.htm [L,R=301]
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.
Reply With Quote
  #3  
Old 09-01-2007, 07:27 AM
fuzzy fuzzy is offline
Senior Member
 
Join Date: May 2005
Location: Milwaukee, WI
Posts: 1,150
Default

I once tried using a regular 301 for a php query, found out it didn't work. And that was all I really needed to know.

When I started working on my own self-coded php project, I made sure I built in an automatic 301 redirect...

Regardless, I'll have to keep Christina's advice in mind! I might still need that one day...
__________________
-Mark
www.fuzzyworld3.com
Reply With Quote
  #4  
Old 09-01-2007, 05:05 PM
-=Seth=- -=Seth=- is offline
Active Member
 
Join Date: Nov 2006
Location: lost in space
Posts: 516
Default

okay i've been playing around with this for hours and i'm beginning to think i'm out of depth

is it normal for different types of browser to interpret htaccess files in different ways, i managed to get the coding you gave me (thanks for that Christina) working but only in explorer and using the pointers you gave me i got this:
Quote:
RewriteEngine on
RewriteRule ^index./php?act=viewCat&catId=75$ http://www.grooming-health.com/proraso.htm [R=301,L]
however it only works in firefox, nothing seems to work in both, also my main concern is google, i dont want to lose the benefit of links coming in to pages that no longer exist, so if browsers dont see it the same hows google going to see it

im stuck can anybody give me anymore pointers in why i'm messing up.
Reply With Quote
  #5  
Old 09-01-2007, 06:58 PM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,145
Default

That's not what I gave you. I gave you directives based on the query string. Did you try it as I gave it?

Not saying it works because it doesn't actually. But this is the kind of thing that needs to be done, along those lines.

Browsers do not interpret .htaccess, they are unaware of it completely. The server acts on its directives regardless of browser or user agent unless the .htaccess fiel has directives based on user agent - I doubt you got any of those.

The only differences I can see between FF and IE would be that in FF it's easy to suppress referrer with the developer toolbar, but there's no such option in IE I'm aware of. Again this would only matter if your .htaccess tests the referrer, which is doesn't.


So I'll keep on thinking because I too need an .htaccess solution for this if it's possible at all.

In the meanwhile I am handling a similar situation with a bit of php code at the top of index.php that tests the query string part by testing $_SERVER['REQUEST_URI'] (NB: not the php variable $_SERVER['QUERY_STRING']), isolating the string between ? and end of the string, testing that, and then do a 301 redirect to wherever if it matches.



Here is where I am testing:

client.webado.net/seth/


And this is the script I put at the top of my index.php :

Quote:
<?php
$request_uri=$_SERVER['REQUEST_URI'];

$qm = strpos($request_uri,"?act=viewCat&catId=75");
if ($qm) {
$goto = "http://www.grooming-health.com/proraso.htm";

header("Location: $goto");
exit;
}

$qm = strpos($request_uri,"?act=viewCat&catId=85");
if ($qm) {
$goto = "http://www.grooming-health.com/dovo-solingen.htm";

header("Location: $goto");
exit;
}
?>
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.

Last edited by webado; 09-01-2007 at 08:19 PM.
Reply With Quote
  #6  
Old 09-01-2007, 08:15 PM
-=Seth=- -=Seth=- is offline
Active Member
 
Join Date: Nov 2006
Location: lost in space
Posts: 516
Default

the original code you gave me worked in firefox but no joy in explorer, i used what you said and searched google under mod rewrite, thats how i developed the second code, (it doesnt work either)
i also found a blog which said htaccess was all voodoo which is beginning to sound plausible

so do i need to stick closer to the original code you gave me, i'll go back and start searching again, thanks Christina
Reply With Quote
  #7  
Old 09-01-2007, 08:21 PM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,145
Default

Until you or I find it, do what I just did above.

The problem with the code I gave for .htaccess is that it does not chop the query string, it tacks it onto the new url where you are redirecting. I need the bit of voodoo to know how to get rid of that. I am getting a headache from reading the Apache manual on this.
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.

Last edited by webado; 09-01-2007 at 08:23 PM.
Reply With Quote
  #8  
Old 09-01-2007, 10:34 PM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,145
Default Got it!

I FOUND IT!


Quote:
Options +Indexes +FollowSymlinks
RewriteEngine on

RewriteCond %{QUERY_STRING} ^act=viewCat&catId=75$ [NC]
RewriteRule index.php http://www.grooming-health.com/proraso.htm? [R=301,L]

RewriteCond %{QUERY_STRING} ^act=viewCat&catId=85$ [NC]
RewriteRule index.php http://www.grooming-health.com/dovo-solingen.htm? [R=301,L]
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.
Reply With Quote
  #9  
Old 09-02-2007, 09:34 AM
-=Seth=- -=Seth=- is offline
Active Member
 
Join Date: Nov 2006
Location: lost in space
Posts: 516
Default

ha ha that works, Christina you are a babe

i got hundreds of those old php pages this is gonna clear up thousands of 404 errors a month

Christina you are without doubt my favorite online imaginary friend, thanks babe youre great
Reply With Quote
  #10  
Old 09-02-2007, 01:50 PM
webado's Avatar
webado webado is offline
Moderator
 
Join Date: Apr 2004
Location: Montreal, Quebec, Canada
Posts: 28,145
Default

Quote:
Originally Posted by -=Seth=- View Post
ha ha that works, Christina you are a babe

i got hundreds of those old php pages this is gonna clear up thousands of 404 errors a month

Christina you are without doubt my favorite online imaginary friend, thanks babe youre great

Oooooh, Seth, you make me blush! *** batting eyelashes ***


But hundreds? Yikes, you're gonna have a lot of lines in your .htaccess file.

You'll need some automation whether you use .htaccess or scripting methinks.

Basically this does externally the opposite of what your url rewriting does internally.

Do you have your current internal url rewriting automated in any way? Or did you add them all manually to your .htaccess file?
__________________
Christina
>>Forum Moderator<<

Please do not PM me for support. The forum is here for that.
Reply With Quote
Reply

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

Forum Jump


All times are GMT. The time now is 01:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.