Rewrite to http://www.yourdomain.com/12

ScallioXTX and All,

Hi again. The reason I decided to use .htaccess ModReWrite was so that Search Engines would crawl the site properly (Index All Pages). And also make URL’s more friendly for people wanting to remember them.

A web site designer told me today that with PHP, as I am using a single page as a template page for all product pages, search engines will only find and hence only rank one page! I thought that all web pages were designed using the PHP and then Search Engines crawl all pages that result from the PHP code. Can anyone tell me (preferably from experience) whether all pages will be ranked by the likes of Google, Bing, Yahoo…etc…

I want to maintain (if not better) the ranking of the current HTML web site online at the moment.

Look forward to your replies,

Matt.

Complete and utter rubbish. Unless the pages have the exact same content google will rank them as different pages.
There are a gazillion pages out there written in php that are distinguished by big G. That should speak for itself really.

Hi ScallioXTX,

You said above regarding getting rid of the .htm on the URL:

As for the .htm, that’s pretty simple; just create a rule that strips the .htm from the requested URL and 301 redirect

I am redesigning a web site using MySQL and PHP hence why I am going to use a Mod ReWrite. If there are say a thousand pages with DIFFERENT URLs (not just the .htm needs removing) I think you would say I need to Mod Rewrite every link to it’s new link. How would I do this?

www.site.com/page_1.htm to www.site.com/page_number_1
www.site.com/free-offers.htm to www.site.com/offers
www.site.com/terms-and-conditions.htm to www.site.com/t-and-c

In this example there is no rule that covers multiple URL changes. How should I write individual 301’s?

Matt.

Yes there is, and the code for it is in post #20 of this thread.

i thought post 20 was just for .htm removal?

I need to specify what URL is the old one and which one it should redirect to. How are the two rules similar/the same?

Matt.

Oh wait I was too fast …

You’re right, you’d need separate 301s for that.


Redirect 301 /page_1.html /page_number_1
Redirect 301 /free-offers.htm /offers
(etc)

I’m using Redirect here instead of RewriteRules because Redirect is a lot faster if you just need to match single instances because it doesn’t use regex but simple string comparisons.

ScallioXTX,

If I use & in the URL what can I get with ModRewrite?

Is it possible to change:
www.site.com/products?product=iphone-4&accessory=car-charger
to
www.site.com/iphone-4-car-charger

ie. Add a hypen in between the two values and make it a simple looking URL?

Matt.

Yes, try this


Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/products
RewriteCond %{QUERY_STRING} product=([a-zA-Z0-9-]+)&accessory=([a-zA-Z0-9-]+)
RewriteRule .? /%1%2? [L,R=301]

:slight_smile:

ScallioXTX,

Thanks for the quick reply. I think either you misunderstood what I want or I am doing something wrong.

The code you suggested changes this:

www.site.com/products?product=iphone-4&accessory=car-charger
to
http://www.site.com/iphone-4car-charger

Which is partly what I want (apart from a hypen is missing - probably easy to add it though?)

What I actually wanted was a Mod Rewrite. Is it possible so that when someone types http://www.site.com/iphone-4-car-charger

it is a Mod-Rewrite for:
www.site.com/products?product=iphone-4&accessory=car-charger

IT MAY NOT BE POSSIBLE and may be I did not explain what I wanted with enough detail.

Is this Mod-Rewrite possible?

Matt.

No you can’t do that using mod-rewrite. The problem is that you have “two types of hyphens”. Let me explain

iphone-4-car-charger

The blue hyphens are connectors within terms, while the red hyphen is a seperator between terms. However, all Apache sees is hyphens and it doesn’t know one from the other, so that’s where the ball stops.

You could however pick another separator, like / or _ and use that. That would work.

As a start on how you would go about that I recommend you read this very good tutorial Data Koncepts - Internet Marketing Specialist

And Matthew, do me a favor will ya, next time you ask a question please a think a bit longer ~how~ you ask it and be ~specific~! Do not ask how to rewrite A to B when what you really want is to rewrite B to A. All I see here is what you type, not what you were thinking while you were typing.