Forum Moderators: phranque
I have tryed with this but seems i am doing something wrong (...and many others as my imagination told me , obviusly i dont know how to use this...)
Rewriterule ^(.*)?osCsid.html$ \.html
i want just to remove the "?osCsid" but only when is beside the ".html"
FROM this "?osCsid.html" to ".html" , keeping what is before the "?osCsid.html"
Thanks in advance
Our Apache Forum Library [webmasterworld.com] also contains several useful tutorials and threads. You may find this one [webmasterworld.com] to be particularly useful in answering your question.
You can find the links to Forum Charters and the Library at the top of almost every page on WebmasterWorld.
Jim
Once the new URLs appear on your pages, you can use mod_rewrite to tell the server where to find the content to be delivered when those new URLs are requested. See this tutorial [webmasterworld.com] in our library.
Due to the limited number of contributors (helpers) here and the high level of demand, we cannot write your code for you; However, we will be happy to help you get your own code working once you have made a good effort, as explained in our Charter.
Thanks,
Jim
[edited by: jdMorgan at 1:31 am (utc) on Feb. 1, 2009]
[edit reason] Example.com [/edit]
http://www.example.com/product_info.php?products_id=90?osCsid=be3c95ee4a1cc5bb1ac878589f323758
"my-product-p-80?osCsid.html"
I would like this to be CHANGE TO
"my-product-p-80.html"
One URL has "my_product-p-80.html" and the other has "product_info.php", so this is confusing.
Jim
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{QUERY_STRING} ^options\=(.*)$
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2%1
RewriteRule ^(.*)-p-(.*).html$ product_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-c-(.*).html$ index.php?cPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-m-(.*).html$ index.php?manufacturers_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pi-(.*).html$ popup_image.php?pID=$2&%{QUERY_STRING}
RewriteRule ^(.*)-t-(.*).html$ articles.php?tPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-a-(.*).html$ article_info.php?articles_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pr-(.*).html$ product_reviews.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-pri-(.*).html$ product_reviews_info.php?products_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-i-(.*).html$ information.php?info_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-links-(.*).html$ links.php?lPath=$2&%{QUERY_STRING}
# Added polls and newsdesk
#RewriteRule ^(.*)-po-([0-9]+).html$ pollbooth.php?pollid=$2&%{QUERY_STRING}
RewriteRule ^(.*)-n-(.*).html$ newsdesk_info.php?newsdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nc-(.*).html$ newsdesk_index.php?newsPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nri-(.*).html$ newsdesk_reviews_info.php?newsdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-nra-(.*).html$ newsdesk_reviews_article.php?newsdesk_id=$2&%{QUERY_STRING}
# BOF: Faqdesk support added by faaliyet
RewriteRule ^(.*)-f-(.*).html$ faqdesk_info.php?faqdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-fc-(.*).html$ faqdesk_index.php?faqPath=$2&%{QUERY_STRING}
RewriteRule ^(.*)-fri-(.*).html$ faqdesk_reviews_info.php?faqdesk_id=$2&%{QUERY_STRING}
RewriteRule ^(.*)-fra-(.*).html$ faqdesk_reviews_article.php?faqdesk_id=$2&%{QUERY_STRING}
# EOF: Faqdesk support added by faaliyet
# RewriteCond %{QUERY_STRING} ^(.+)?osCsid.html$ [NC]
# RewriteRule (.*) $1?%1.html [R=301,L]
# Ultimate SEO URLs END
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /error404.html
(.*) parts in the patterns are very inefficient, meaning that dozens or hundreds of trial matches have to be made for each URL for each and every rule. Most of those should be replaced by something like
([^\-]+) and ([^.]+) just as long as the part to be captured does not contain any hyphens or periods. Additionally, every rule needs an
[L] appended to the end, to stop processing at that point. [edited by: g1smd at 9:56 pm (utc) on Feb. 1, 2009]
All I can tell you is that you will have problems if the "products_id" query name/value is missing with this rule:
# RewriteCond %{QUERY_STRING} ^(.+)?osCsid.html$ [NC]
# RewriteRule (.*) $1?%1.html [R=301,L]
# Redirect requested URL [b]with[/b] "products_id" in query string
RewriteCond %{QUERY_STRING} ^[b]([^?&]+)[?&]os[/b]Csid\.html$ [NC]
RewriteRule (.*) http://www.example.com/$1?%1.html [R=301,L]
#
# Redirect requested URL [b]without[/b] "products_id" in query string
RewriteCond %{QUERY_STRING} ^osCsid\.html$ [NC]
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
-----
Now, I'm going to suggest some improvements to your existing rules, because most of them are very inefficient, and some of them should not even be needed. Making your regular-expressions patterns *much* more specific will likely improve your server performance noticeably. Even if it doesn't, it will help to keep you from having to upgrade your server so soon if your site gets very successful/busy:
Again, most of this is just making your patterns more specific. We're also adding the [L] flag except where we *know* it should not be used, escaping all literal periods in regex patterns, and getting rid of the un-referenced back-references.
RewriteCond %{HTTP_HOST} ^example\.com [OR]
# catch FQDN and/or appended port number
RewriteCond %{HTTP_HOST} ^www\.example\.com(\.¦\.?:[0-9]+)$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
RewriteCond %{QUERY_STRING} ^options=(.*)$
RewriteRule ^[^\-]+-p-([^.]+)\.html$ product_info.php?products_id=$1%1 [L]
RewriteRule ^[^\-]+-p-([^.]+)\.html$ product_info.php?products_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-c-([^.]+)\.html$ index.php?cPath=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-m-([^.]+)\.html$ index.php?manufacturers_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-pi-([^.]+)\.html$ popup_image.php?pID=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-t-([^.]+)\.html$ articles.php?tPath=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-a-([^.]+)\.html$ article_info.php?articles_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-pr-([^.]+)\.html$ product_reviews.php?products_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-pri-([^.]+)\.html$ product_reviews_info.php?products_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-i-([^.]+)\.html$ information.php?info_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-links-([^.]+)\.html$ links.php?lPath=$1&%{QUERY_STRING} [L]
# Added polls and newsdesk
#RewriteRule ^[^\-]+-po-([0-9]+)\.html$ pollbooth.php?pollid=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-n-([^.]+)\.html$ newsdesk_info.php?newsdesk_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-nc-([^.]+)\.html$ newsdesk_index.php?newsPath=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-nri-([^.]+)\.html$ newsdesk_reviews_info.php?newsdesk_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-nra-([^.]+)\.html$ newsdesk_reviews_article.php?newsdesk_id=$1&%{QUERY_STRING} [L]
# BOF: Faqdesk support added by faaliyet
RewriteRule ^[^\-]+-f-([^.]+)\.html$ faqdesk_info.php?faqdesk_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-fc-([^.]+)\.html$ faqdesk_index.php?faqPath=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-fri-([^.]+)\.html$ faqdesk_reviews_info.php?faqdesk_id=$1&%{QUERY_STRING} [L]
RewriteRule ^[^\-]+-fra-([^.]+)\.html$ faqdesk_reviews_article.php?faqdesk_id=$1&%{QUERY_STRING} [L]
# EOF: Faqdesk support added by faaliyet
#
# Redirect requested URL with "products_id" in query string
RewriteCond %{QUERY_STRING} ^([^?&]+)[?&]osCsid\.html$ [NC]
RewriteRule (.*) http://www.example.com/$1?%1.html [R=301,L]
#
# Redirect requested URL without "products_id" in query string
RewriteCond %{QUERY_STRING} ^osCsid\.html$ [NC]
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
#
# Ultimate SEO URLs END
#
# Do not do this! Apache will return a 200-OK status, confusing search
# engine spiders, and potentially damaging your search rankings!
# Let Apache handle missing-resource errors normally, instead.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule (.*) /error404.html
Based on the number of inefficiencies found and corrected in the code, I think you will probably notice a speed-up on your server with these changes...
Jim