 |
|

02-20-2006, 08:30 AM
|
 |
SEO Junior and a half
|
|
Join Date: Feb 2006
Location: NH (US)
Posts: 44
|
|
|
Specific mod rewrite problem
Firstly - I hope it is OK to discuss mod rewrite in the forum. I didn't see a forum dedicated to that purpose and I am a newbie (in this forum).
I have tried to figure this out on my own, but I am struggling -
I have implemented mod rewrite to allow requests for
/tb-1500.html
actually access my script file:
/****-****.php?id=1500
I am using the following line in my .htaccess to allow this:
RewriteRule ^tb-(.*).html /****-****-ensembles.php?id=$1
That is working great. Now I want to make sure that requests coming in for /****-****-ensembles.php?id=1500 are served up a 301 redirect to /tb-1500.html. I have tried several things that don't seem to work. Could anyone help me with the syntax or point me in the right direction to accomplish both the rewrite and the redirect?
Thanks in advance.
Last edited by sparrowhawk : 04-21-2006 at 06:07 AM.
Reason: remove kw
|

02-20-2006, 09:23 AM
|
 |
SEO GUY Moderator
|
|
Join Date: Sep 2004
Location: Antalya, Turkey
Posts: 4,238

|
|
|
Hi,
Maybe you should post the complete htaccess so we can have a look at it.
In any case, can't you just add a [R=301,L].Also you are missing a $
so the complete htaccess would look something like
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
^tb-(.*).html$ /thomasville-bedding-ensembles.php?id=$1 [R=301,L]
The problem is that you may need to "escape" the hyphen in tb- with an \ but I'm not sure.... Let us know how you get on.
Cheers,
Paz.
__________________
10.3 million entries for Hotels in Turkey but I'm still chipping away.
|

02-20-2006, 09:47 AM
|
 |
SEO Junior and a half
|
|
Join Date: Feb 2006
Location: NH (US)
Posts: 44
|
|
|
Here is my complete .htaccess file:
---------------------------------
ErrorDocument 404 http://www.ajmoss.com/404.php
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^index.php$ http://www.ajmoss.com/ [R=301,L]
RewriteRule ^tb-(.*).html /thomasville-bedding-ensembles.php?id=$1
RewriteRule ^cat-(.*).html /categories.php?cat=$1
RewriteCond %{HTTP_HOST} !^www\.ajmoss\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule (.*) http://www.ajmoss.com/$1 [R]
---------------------------------
The second rewrite rule is the one that is working to make requests for "tb-1500.html" actually access the file "thomasville-bedding-ensembles.php?id=1500". This is actually working great.
The problem is that Google still has pages like "thomasville-bedding-ensembles.php?id=1500" in their index. I have changed all links on the site to point to the new page: "tb-1500.html". I am concerned that Google will index the new nicer urls and penalize me for dup content. I would like any requests for "thomasville-bedding-ensembles.php?id=1500" to get served up a 301 redirect to tb-1500.html. Does that make sense?
If I just add the 301 syntax: [R=301,L] then requests for tb-1500.html no longer serve up the content of thomasville-bedding-ensembles.php?id=1500.
So basically I can get one or the other to work, the rewrite or the redirect, but I can't get them both to work simultaneously.
Thanks again for any help.
Last edited by sparrowhawk : 02-20-2006 at 09:53 AM.
Reason: trying to remove hyperlinks???
|

02-20-2006, 10:38 AM
|
 |
SEO GUY Moderator
|
|
Join Date: Sep 2004
Location: Antalya, Turkey
Posts: 4,238

|
|
Hi,
That htaccess is really horrible.... haha sorry!
I'll have more one try before I go to bed, then we'll have to do it tomorrow.
Yes, it's important to redirect the urls as well as re-write them, but adding the r=301 should do that.
If you use just this below (and I've made some changes so cut and paste this please
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^tb-(.*).html$ thomasville-bedding-ensembles.php?id=$1 [R=300, L]
RewriteRule ^cat-(.*).html$ categories.php?cat=$1 [R=300, L]
You say it doesn't "serve up the content", but what exactly do you see?
Cheers,
Paz.
__________________
10.3 million entries for Hotels in Turkey but I'm still chipping away.
|

02-20-2006, 10:55 AM
|
 |
SEO Junior and a half
|
|
Join Date: Feb 2006
Location: NH (US)
Posts: 44
|
|
Quote:
|
Originally Posted by Paz
Hi,
That htaccess is really horrible.... haha sorry!
I'll have more one try before I go to bed, then we'll have to do it tomorrow.
Yes, it's important to redirect the urls as well as re-write them, but adding the r=301 should do that.
If you use just this below (and I've made some changes so cut and paste this please
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^tb-(.*).html$ thomasville-bedding-ensembles.php?id=$1 [R=300, L]
RewriteRule ^cat-(.*).html$ categories.php?cat=$1 [R=300, L]
You say it doesn't "serve up the content", but what exactly do you see?
Cheers,
Paz.
|
I get an internal server error message with this syntax.
I looks like the rule you have set up would forward requests for tb-1234.html to the page thomasville-bedding-ensembles.php?id=1234. Isn't that the opposite of what I want to accomplish?
Thanks for your help and patience. I am a newbie in the world of mod rewrite and I know your time is important.
|

02-20-2006, 04:42 PM
|
 |
SEO Junior and a half
|
|
Join Date: Feb 2006
Location: NH (US)
Posts: 44
|
|
Quote:
|
Originally Posted by Paz
That htaccess is really horrible.... haha sorry!
|
No you're absolutely right. I don't really know what I am doing in regard to mod rewrite. Thanks for taking the time to help.
Quote:
|
Originally Posted by Paz
You say it doesn't "serve up the content", but what exactly do you see?
|
I get a 404 when requesting the document: "tb-1500.html" which is working great with the ugly file I'm using. I just can't seem to have cake and eat it with the mod rewrite vodoo.
As always - thanks for any help.
|

02-20-2006, 11:01 PM
|
 |
SEO GUY Moderator
|
|
Join Date: Sep 2004
Location: Antalya, Turkey
Posts: 4,238

|
|
|
Hi,
well if your htaccess partly works, then I must have it wrong not you.
I've PM'd a mod_rewrite heavyweight for some help.
Cheers,
Paz.
__________________
10.3 million entries for Hotels in Turkey but I'm still chipping away.
|

02-21-2006, 05:54 AM
|
 |
SEO Junior and a half
|
|
Join Date: Feb 2006
Location: NH (US)
Posts: 44
|
|
Quote:
|
Originally Posted by Paz
well if your htaccess partly works, then I must have it wrong not you.
|
Thanks so much. I just want to beat the bots.
|

02-22-2006, 02:13 AM
|
 |
SEO Junior and a half
|
|
Join Date: Oct 2004
Posts: 84
|
|
Code:
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^tb\-([^.]+)\.html$ thomasville-bedding.php?id=$1 [L]
is it
thomasville-bedding-ensembles.php
or
thomasville-bedding.php
only one script can have
tb\-([^.]+)\.html
Code:
ErrorDocument 404 http://www.ajmoss.com/404.php
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^index\.php$ http://www.ajmoss.com/ [R=301,L]
RewriteRule ^tb\-([^.]+)\.html$ thomasville-bedding-ensembles.php?id=$1 [L]
RewriteRule ^cat\-([^.]+)\.html$ categories.php?cat=$1 [L]
RewriteCond %{HTTP_HOST} !^www\.ajmoss\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule (.*)$ http://www.ajmoss.com/$1 [R]
Quote:
|
Originally Posted by sparrowhawk
So basically I can get one or the other to work, the rewrite or the redirect, but I can't get them both to work simultaneously.
|
When you try to do both a 301 redirect and change the URLs, they fight with each other. 301 redirect..no, change URL, no 301 redirect, no....like a infinite loop.
If Google already links to everything it might be better to not do mod_rewrite.
|

02-22-2006, 06:50 AM
|
 |
SEO Junior and a half
|
|
Join Date: Feb 2006
Location: NH (US)
Posts: 44
|
|
Quote:
|
Originally Posted by Nintendo
When you try to do both a 301 redirect and change the URLs, they fight with each other. 301 redirect..no, change URL, no 301 redirect, no....like a infinite loop.
|
That makes sense. So no way to accomplish both . . . How strange??? Seems like something that people would want to do often. Pretty up some urls and then redirect the old ones to the new ones.
Quote:
|
Originally Posted by Nintendo
If Google already links to everything it might be better to not do mod_rewrite.
|
Will I definitely get penalized for dup content? Or will they just replace the old urls with the new ones?
|
 |
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|