Hi all,
I had an overlooked problem with my URL rewrites, products are shown as www.domain.com/productname50ml.html instead of www.domain.com/productname-50ml.html
The problem initially was that product names were not seperated with a '-'. This has now been fixed but my problem is I want to redirect the original urls with a 301 redirect so that it goes to the new url seperated with a '-'.
####################Original .htaccess that did not seperate urls with a '-' __
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} union [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
RewriteCond %{QUERY_STRING} select [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
RewriteCond %{QUERY_STRING} jatest [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
RewriteCond %{QUERY_STRING} http [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
</IfModule>
## Add these to your .htaccess file so that only one way to your site exists, either http://yoursite.com and http://www.yoursite.com ... the following adds the www if it's missingtml
ErrorDocument 404 /errordocs/404error.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
## If you'd like your site to go to http://mysite.com instead of http://www.mysite.com, add these changes instead (remove the two pound symbols before each line in the section below, and delete the section above):
##RewriteEngine On
##RewriteCond %{HTTP_HOST} ^www.yoursite.com$ [NC]
##RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
## the following makes sure the correct mime type is sent for the .htc file
AddType text/x-component .htc
##### NOTE: Replace /shop/ with the relative web path of your catalog in the "Rewrite Base" line below:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# From Ultimate SEO URLs
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-c-(.*).html$ index\.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-m-([0-9]+).html$ index\.php?main_page=index&manufacturers_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pi-([0-9]+).html$ index\.php?main_page=popup_image&pID=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pr-([0-9]+).html$ index\.php?main_page=product_reviews&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pri-([0-9]+).html$ index\.php?main_page=product_reviews_info&products_id=$2&%{QUERY_STRING} [L]
# For Open Operations Info Manager
RewriteRule ^(.*)-i-([0-9]+).html$ index\.php?main_page=info_manager&pages_id=$2&%{QUERY_STRING} [L]
# For dreamscape's News & Articles Manager
RewriteRule ^news/?$ index\.php?main_page=news&%{QUERY_STRING} [L]
RewriteRule ^news/rss.xml$ index\.php?main_page=news_rss&%{QUERY_STRING} [L]
RewriteRule ^news/archive/?$ index\.php?main_page=news_archive&%{QUERY_STRING} [L]
RewriteRule ^news/([0-9]{4})-([0-9]{2})-([0-9]{2}).html$ index\.php?main_page=news&date=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^news/archive/([0-9]{4})-([0-9]{2}).html$ index\.php?main_page=news_archive&date=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+)-comments.html$ index\.php?main_page=news_comments&article_id=$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+).html$ index\.php?main_page=news_article&article_id=$2&%{QUERY_STRING} [L]
# All other pages
# Don't rewrite real files or directories
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ index\.php?main_page=$1&%{QUERY_STRING} [L]
##########____Url rewrite that does have the '-'##############################__
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} union [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
RewriteCond %{QUERY_STRING} select [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
RewriteCond %{QUERY_STRING} jatest [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
RewriteCond %{QUERY_STRING} http [NC]
RewriteRule .* /http [F,NC]
RewriteRule http: /http [F,NC]
</IfModule>
## Add these to your .htaccess file so that only one way to your site exists, either http://yoursite.com and http://www.yoursite.com ... the following ##adds the www if it's missingtml
##RewriteEngine On
##RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
##RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
## If you'd like your site to go to http://mysite.com instead of http://www.mysite.com, add these changes instead (remove the two pound symbols before each line in the section below, and delete the section above):
##RewriteEngine On
##RewriteCond %{HTTP_HOST} ^www.yoursite.com$ [NC]
##RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
## the following makes sure the correct mime type is sent for the .htc file
AddType text/x-component .htc
##### NOTE: Replace /shop/ with the relative web path of your catalog in the "Rewrite Base" line below:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# From Ultimate SEO URLs
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-c-(.*).html$ index\.php?main_page=index&cPath=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-m-([0-9]+).html$ index\.php?main_page=index&manufacturers_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pi-([0-9]+).html$ index\.php?main_page=popup_image&pID=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pr-([0-9]+).html$ index\.php?main_page=product_reviews&products_id=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)-pri-([0-9]+).html$ index\.php?main_page=product_reviews_info&products_id=$2&%{QUERY_STRING} [L]
# For Open Operations Info Manager
RewriteRule ^(.*)-i-([0-9]+).html$ index\.php?main_page=info_manager&pages_id=$2&%{QUERY_STRING} [L]
# For dreamscape's News & Articles Manager
RewriteRule ^news/?$ index\.php?main_page=news&%{QUERY_STRING} [L]
RewriteRule ^news/rss.xml$ index\.php?main_page=news_rss&%{QUERY_STRING} [L]
RewriteRule ^news/archive/?$ index\.php?main_page=news_archive&%{QUERY_STRING} [L]
RewriteRule ^news/([0-9]{4})-([0-9]{2})-([0-9]{2}).html$ index\.php?main_page=news&date=$1-$2-$3&%{QUERY_STRING} [L]
RewriteRule ^news/archive/([0-9]{4})-([0-9]{2}).html$ index\.php?main_page=news_archive&date=$1-$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+)-comments.html$ index\.php?main_page=news_comments&article_id=$2&%{QUERY_STRING} [L]
RewriteRule ^news/(.*)-a-([0-9]+).html$ index\.php?main_page=news_article&article_id=$2&%{QUERY_STRING} [L]
# All other pages
# Don't rewrite real files or directories
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*).html$ index\.php?main_page=$1&%{QUERY_STRING} [L]
##########################################################################################____
So if any one understands my problem, how do I rewrite the old urls to redirect to the new URL's
Thanks in advance!
Bookmarks