Avatar of Member_5340450
Member_5340450

asked on 

duplicate content

How do I rewrite the following url so Google ignores that it is duplicate content?

Bad URL I want de-indexed:

example.com/cart/index.php?option1=a&option2=b&option3=c

Good url I want indexed:

example.com/nice-sef-address

Apache Web ServerRegular ExpressionsWeb Servers

Avatar of undefined
Last Comment
Derek Jensen
Avatar of Bryan Butler
Bryan Butler
Flag of United States of America image

Avatar of Member_5340450
Member_5340450

ASKER

I have read and read, I need an actual answer, thanks.
Avatar of farzanj
farzanj
Flag of Canada image

Sorry, what is the question?  You need to decide how to name "nice-sef-address" or how to forward to the nice address?

If you can give me the rules of what you want to forward where, I can give you the commands
Avatar of Member_5340450

ASKER

the rules are in the original question. I'm looking for the mod rewrite EXACT syntax. Don't mean to shout but you know how picky .htaccess is.
Avatar of Member_5340450

ASKER

Here's a more real world example, it's the same pattern as in my first post

http://www.example.com/shop/index.php?main_page=product_info&products_id=7

I want to 301 redirect that to www.example.com

I have others, actually, that I need to 301 redirect to

www.example.com/course-registration

This is a joomla site, and joomla sees "shop" as an undefined component.


Avatar of farzanj
farzanj
Flag of Canada image

For starters:  Use R=301 when you are totally satisfied with working.

RewriteEngine On
RewriteBase /
RewriteRule * /course-registration [R,L]

Avatar of Member_5340450

ASKER

Is that going to redirect all the url's? I only want the ones that match the pattern.
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

Are you looking specifically (and only just) for 'shop'? If so, this should work:
RewriteEngine On
RewriteBase /
RewriteRule ^shop/index.php / [R,L]
RewriteRule * /course-registration [R,L]

Open in new window

The asterisk in the second rule you should replace with whatever regex pattern you need to look for to redirect to course-registration. :-)
Avatar of Member_5340450
Member_5340450

ASKER

Thanks for writing, I honestly don't remember :)

I supposed we could have a theoretical conversation -

how would you change

example.com/shop/index.php

so that it becomes

example.com/course-registration

Is the asterisk looking at the query parameters? When you say "whatever regex pattern you need to look for," where are we looking for this pattern, the parameters?
ASKER CERTIFIED SOLUTION
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Member_5340450

ASKER

OK so the pattern is --

RewriteRule thing-to-search-for thing-to-change-it-to [options]

Is that right?
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

Yes, that's correct. :-)
Avatar of Member_5340450

ASKER

So if I want to change:

example.com/shop/index.php

so that it becomes

example.com/course-registration

I would do this?

RewriteRule ^shop/index.php course-registration  [R,L]
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

That looks to be correct...so does that work for you?
Avatar of Member_5340450

ASKER

It was more of a theoretical question. This comes up all the time and I didn't get how the patterns worked.
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

Ah. Yes, .htaccess regex is a bit..."off". ;-)
Avatar of Member_5340450

ASKER

I actually get regular expressions. It's the looping through htaccess that hurts :)
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

You and me Both; I don't think I'll ever fully wrap my head around all the .htaccess rules...
Web Servers
Web Servers

A web server refers to the software that helps to deliver web content that can be accessed either through the Internet or through an intranet. The primary function of a web server is to store, process and deliver web pages to clients. The communication between client and server takes place using the Hypertext Transfer Protocol (HTTP). The most common use of web servers is to host websites, but there are other uses such as gaming, data storage, running enterprise applications, handling email, FTP, etc.

33K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo