homepage Welcome to WebmasterWorld Guest from 204.236.255.69
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Rules not working as expected?
I'm fairly a n00b on htacess and this one's thrown me for a loop.
ripthesystem




msg:4331027
 4:12 pm on Jun 25, 2011 (gmt 0)

I'm fairly a n00b on htacess and this one's thrown me for a loop. Mostly all I've done are simple 301's and correcting minor errors I've encountered. I also usually have access to the server so I can test by trial and error and learn that way. In this particular case every time I want to try a code change, I have to submit a support ticket.. big hassle :-)

Anyways, the problem I'm having is with a shopping cart system called CoreCommerce.

This URL is generated by the cart:
[mysite.com...]

and we want it 301'd to this:
[mysite.com...]

Both of those URL's are valid. Both are generated. But they both exist and it's creating duplicate content issues across Google. Every single item in the store has both URL's indexed and we are now getting links to both and we really just want the bottom one.

Any suggestions? The .htaccess file is below.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule ^(.*)$ http://www.mysite.com/$1 [r=301,L]
RewriteRule ^[Ff][Ee][Aa][Tt][Uu][Rr][Ee][Dd].html?$ cart.php?m=featured
RewriteRule ^[Nn][Ee][Ww]_[Aa][Rr][Rr][Ii][Vv][Aa][Ll][Ss].html?$ cart.php?m=new_arrivals
RewriteRule ^[Ss][Pp][Ee][Cc][Ii][Aa][Ll][Ss].html?$ cart.php?m=on_sale
RewriteRule ^[Tt][Oo][Pp]_[Ss][Ee][Ll][Ll][Ee][Rr][Ss].html?$ cart.php?m=top_sellers
RewriteRule ^[Ss][Pp][Ll][Aa][Ss][Hh][-_][Pp][Aa][Gg][Ee]\.html?$ cart.php?m=splash
RewriteRule ^.*_v([\d]+)/?$ cart.php?m=product_vendor_list&v=$1 [L]
RewriteRule ^.*-v([\d]+)/?$ cart.php?m=product_vendor_list&v=$1 [L]
RewriteRule ^.*_v([0-9]+)/?$ cart.php?m=product_vendor_list&v=$1 [L]
RewriteRule ^.*-v([0-9]+)/?$ cart.php?m=product_vendor_list&v=$1 [L]
RewriteRule ^.*_c([\d]+)/?$ cart.php?m=product_list&c=$1 [L]
RewriteRule ^.*-c([\d]+)/?$ cart.php?m=product_list&c=$1 [L]
RewriteRule ^.*_c([0-9]+)/?$ cart.php?m=product_list&c=$1 [L]
RewriteRule ^.*-c([0-9]+)/?$ cart.php?m=product_list&c=$1 [L]
RewriteRule ^.*[-_]p([0-9]+).html?,gwo$ cart.php?m=product_detail&p=$1&gwo=Y [R=301,L]
RewriteRule ^.*_p([\d]+).html?,?([\d])?,?([\d])?$ cart.php?m=product_detail&p=$1&special=$2&related=$3 [L]
RewriteRule ^.*-p([\d]+).html?,?([\d])?,?([\d])?$ cart.php?m=product_detail&p=$1&special=$2&related=$3 [L]
RewriteRule ^.*_p([0-9]+).html?,?([0-9])?,?([0-9])?$ cart.php?m=product_detail&p=$1&special=$2&related=$3 [L]
RewriteRule ^.*-p([0-9]+).html?,?([0-9])?,?([0-9])?$ cart.php?m=product_detail&p=$1&special=$2&related=$3 [L]
RewriteRule ^cart\.html?([^/]*)$ cart.php$1
RewriteRule ^(.*/wysiwyg/.*\.html?)$ $1 [L]
RewriteRule ^(.*)/$ cart.php?m=content&explode=Y&name=$1 [L]
RewriteRule ^(.*)/([^/]+)\.(html?)$ cart.php?m=content&name=$2&path=$1&ext=$3
RewriteRule ^([^\.]+)/$ cart.php?m=content&explode=Y&name=$1 [L]
RewriteRule ^([^\.]+)$ cart.php?m=content&name=$1 [L]
RewriteRule ^([^/]+)\.(html?)$ cart.php?m=content&name=$1&ext=$2
RewriteRule ^items?/([\d]+)/?$ cart.php?m=product_detail&p=$1
RewriteRule ^products?/([\d]+)/?$ cart.php?m=product_detail&p=$1
</IfModule>


Thank you in advance!

 

g1smd




msg:4331044
 5:53 pm on Jun 25, 2011 (gmt 0)

Only every use the .* pattern if it is the LAST item before the $ end anchor.

Make sure the non-www to www redirect is the LAST redirect in the list of redirects otherwise you will generate an unwanted multi-step redirection chain for some requests.

The mixed-case patterns are best done with the [NC] flag, and not [Ww][Or][Rr][Dd].

Don't forget to escape all literal periods in patterns.

Every redirect needs the [R=301,L] flags. Every rewrite needs the [L] flag.

Every wildcard part of every rewritten request must be validated other wise malicious links of the form
example.com/this-product-is-junk-902462-acme-widget will result in your content being indexed for these "spoofed" URLs.

I can't see what else you want to change. You must use example.com in your question in order to stop forum auto-linking.

ripthesystem




msg:4331056
 6:59 pm on Jun 25, 2011 (gmt 0)

@g1smd - thank you very much for your detailed reply. You have given me a lot to research and learn about. To be honest I feel a bit like I'm reading Greek here :)

I'll dive into this, see if I can rework it and post back later. Thank you again!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved