http://www.example.com/mls.html?subdivision=MAJESTIC%20BEACH%20TOWERS
&subdivision=MAJESTIC%20BEACH%20TOWERS%20PHASE%20I
&subdivision=MAJESTIC%20BEACH%20TOWERS%20PHASE%20II&search=Search
The issue is that the "mls.html?subdivision" or "?" is causing the search engins not to index the links from this page. How do you create a script that would allow me to substatute or rename the search result URL while still calling for the same results?
Additionally, how do I write a script that will dynamically rename the search result url's with fields in my database? An example would be to rename:
http://www.example.com/mls.html?mls_acct=382327
My database has fields like:
Subdivision
City
Property_type
Address
to http://www.example.com/"City"_"first_subdevision"_"property_type"_"address".html
[edited by: tedster at 4:24 am (utc) on May 30, 2008]
[edit reason] use example.com, and add line breaks to long url [/edit]
However, it sounds like you might make the first mistake most people make with mod_rewrite, and get it backwards. Its common to think you'll be changing some complicated query string to a simple URL.
The truth is you work in exactly the opposite way.
This is what allows your script to keep functioning for **BOTH** your complex URL's and the serp-happy ones.
Once in place, you begin putting these links on your pages:
<a href="/City-first-subdivision-property-type-address">City; Subdiv, Prop Type</a>
Mod rewrite redirects it to your perl or php script. The way I do it is I have these URL's stored in a DB. If I detect a / after the domain name, I take everything after the domain name and see if it's a URL I have stored. To simplify:
mydomain.com/my-product
(split it up, then)
select prod_id from prod_urls where url like '%my-product%';
If this returns an ID, my script carries on as usual:
$qs{'pid'}=$whatever_result_was
products.cgi?pid=$qs{'pid'}
How you get here is simple. You make sure those URL's, or directories, do not exist on your site. Then in your domain level .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cgi-bin/products.cgi [L]
What this says is "if it's not a file and it's not a directory, send it to products.cgi."
I have this automated so whenever a new product is added, the URL for it is automatically created and stored. Zero maintenance converting the serp-y URL's to query strings. There are a number of ways to do this "conversion," whatever works for you in programming is what works for you.
More info here in the Apache Forum:
[webmasterworld.com...]
and mod_rewrite docs:
[httpd.apache.org...]