Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

migrated system with new urls

I am switching system from a MVC to a custom code system. Currently we are using this format for urls:

index.php?part=CAPACITOR&type=CERAMIC&model=0805&page=spec

I need now to rewrite urls like to be more nice for user like

mysitecom/CAPACITOR/
mysitecom/CAPACITOR/CERAMIC/
mysitecom/CAPACITOR/CERAMIC/0805/spec.html#2

where #1 and #2 are the pages loaded in jquery. The developer use the old way using /index.php/CAPACITOR/CERAMIC/0805/spec.html

Because I don't think using the index.php in the url is good, what can I do to make this better?

like image 612
Kyra Avatar asked Feb 02 '12 01:02

Kyra


People also ask

What happens when you migrate a website?

In a website migration, a website undergoes substantial URL, structure, content, UX, design, or platform changes. It could be everything from updating the layout of your website to changing the URL structure, or moving your website to a new domain or content management system (CMS).

What does migrating website mean?

A site migration is a term broadly used by SEO professionals to describe any event whereby a website undergoes substantial changes in areas that can significantly affect search engine visibility — typically changes to the site's location, platform, structure, content, design, or UX.

Does server migration affect SEO?

So, Does Website Migration Affect SEO? Any server change carries a slight SEO risk with or without modifications to your website, but that's not necessarily a bad thing. You see, migrations primarily affect site speed. So if you're migrating to a host like A2 Hosting, you'll notice increased site speed.


1 Answers

Here's what you need to use

RewriteEngine On
RewriteBase /

RewriteRule ^([a-z0-9\-_]+)/?$ index.php?part=$1&type=all&model=all&page=index [L,NC]
RewriteRule ^([a-z0-9\-_]+)/([a-z0-9\-_]+)/?$ index.php?part=$1&type=$2&model=all&page=index [L,NC]
RewriteRule ^([a-z0-9\-_]+)/([a-z0-9\-_]+)/([a-z0-9\-_]+)/?$ index.php?part=$1&type=$2&model=$3&page=index [L,NC]
RewriteRule ^([a-z0-9\-_]+)/([a-z0-9\-_]+)/([a-z0-9\-_]+)/([a-z0-9\-_\.]+)\.html$ index.php?part=$1&type=$2&model=$3&page=$4 [L,NC]

So when a folder (example CERAMIC) is not provided you can add a flag to load all, same idea for model. It means that if only the first part is provided only he first rule will be used. As of the page.html by default you can load the index.

Now, a-z0-9\-_ means any letters, numbers, dashes and underscore ONLY. You can use ([^/]+) if you prefer that will allow you to use more characters.

The L mean last meaning if the rule match, it will stop. NC means non case so A = a or ABC = abc.

like image 146
Book Of Zeus Avatar answered Oct 06 '22 22:10

Book Of Zeus