View Full Version : Rewrite problems
ian_ok
Apr 2nd 2006, 8:30 am
This is my rewite:
RewriteRule ^property_details/propertiesforsale-([0-9]*).html /property_details/listingview.php?listingID=$1
So now all links on my websites are as such:
site . com/property_details/propertiesforsale-55.html
which all work fine.
But when you click on a link from Google etc, such as:
site . com/property_details/listingview.php?listingID=68
This page loads and you are not redirected to propertiesforsale-68.html
If I change the rewrite round I get 404 errors:
RewriteRule ^/property_details/listingview.php?listingID=$1 htt p://w ww.site . com/property_details/propertiesforsale-([0-9]*).html
[edit] Even if I add
redirect 301 /property_details/listingview.php?listingID=55 htt p://w ww.site . com/property_details/propertiesforsale-55.html
It doesn't work, can you have a redirect 301 and a rewrite for the same file???
Thanks Ian
Nintendo
Apr 3rd 2006, 2:59 am
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^property_details/propertiesforsale\-([0-9]*)\.html$ property_details/listingview.php?listingID=$1
RewriteRule ^property_details/listingview\.php?listingID\=([0-9]*)$ http://www.site.com/property_details/propertiesforsale-$1.html [R=301,L]
ian_ok
Apr 3rd 2006, 10:08 am
Hi Nintendo, Sorry but it doesn't work.
Not sure what the problem could be, I had the same problem with another file using the same d/b....so guess that all my links on the site point to the new .html so in time the .php?listingID=$1 will drop out of G and other SE's.
Ian
ian_ok
Apr 3rd 2006, 2:08 pm
What I've done is to create a 301 for the file listingview.php:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ht tp://w ww.site.com");
exit(); ?>
And re-named the file that rewrites listingview_2 and changed the .htaccess
I think this will be better?????
Ian
Nintendo
Apr 3rd 2006, 3:23 pm
I'm guessing you got the infinite loop, while on my server it is able to both change the URL, and redirect to the new URL!!
mihaidamianov
Apr 3rd 2006, 3:25 pm
Some hosting services are really bad at handling mod_rewrites. Netfirms.com, for example, gives me a lot of trouble with this. Maybe it's your case too.
ian_ok
Apr 3rd 2006, 10:03 pm
Thanks for that, I presume you mean an infinite loop is because the URL links have been changed to point to the .html (which doesn't exist) and then you are trying to write anything that accesses the the real file via the the old URL....Not very well explained....!
eg.
1st For any requests for w ww.site.com/property_details/propertiesforsale-20.html use the listingview.php file but write the URL as requested
2nd For any requests for w ww.site.com/property_details/listingview.php?listingID=20 write this as w ww.site.com/property_details/propertiesforsale-20 but this causes the infinte loop as in plain old English terms.....
...It doesn't know if it's coming or going!
Ian
sarathy
Apr 12th 2006, 8:01 am
Sorry for bringing up this old thread.,
I too have the same problem and thought of posting it here itself instead of a new thread.,
Our old urls was like:
mysite.com/js/listings.php?emp=abcd-100&pg=12
I rewrote this urls to:
mysite.com/india/abcd-100/12/
All But yahoo searchengine still crawls our old url.
Now i want to redirect
all urls in the format:
mysite.com/js/listings.php?emp=abcd-100&pg=12 to:
mysite.com/india/abcd-100/12/
Pls help :)
ian_ok
Apr 12th 2006, 9:01 am
What i did to oover come this is the following:
#listingview
RewriteRule ^property_details/propertiesforsale-([0-9]*).html /property_details/listingview1.php?listingID=$1
RewriteRule ^property_details/propertiesforsale.html /property_details/listingview1.php
listingview.php was the original file that I wanted to rewrite and whould have the same problem as yourself so I made a file called listingview1.php exactly the same as listingview.php and changed the htaccess as above then with listingview.php I added the following to redirect to the home page, that way the bots will recrawl the new HTML url's and delist the old .php file
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ht tp://w w w.site.com");
exit(); ?>
Best of luck Ian
sarathy
Apr 13th 2006, 1:11 am
Thanks for your suggestion ian, :)
But we have several urls like this and its not possible for us to create a page like that :(
Is there any other suggestion
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.