We have an ecommerce site right now that carries a range of brands. The brand pages carry urls as follows:
http://www.<DOMAIN>.com/catalog/brand/view?id=2
We need to utilize more friendly (seo-friendly) urls such as:
http://www.<DOMAIN>.com/<BRAND>
but such that it would resolve #1 above.
Is this done in .htaccess files in the root? If so, what is the correct way to go about this?
Keep in mind URL#1 is the legitimate address, but we want to utilize the URL#2 format for linking. It's not a 301 type redirect is it? That's more "permanent" unless I misunderstood it or something, no?
Many thanks.
The apache feature you are looking for is called
mod_rewrite
. You should be able to google and find good resources for help here.The basic idea is you'll specify a regular expression matching and then a replacement pattern. You can set it to do a 301 redirect, but the default is to not redirect the user, just access the re-written url.
Here's an example:
The RewriteRule says to rewrite any matching url(.*) to index.php. This is not particularly useful for most files. I'm sure you'll have plenty of examples as this is a common problem.
You can do it by adding a .htaccess on the index or doing the configuration in the httpd.conf.
Here you have a tool that can help you. What you need is an inflector
I hope this helps you.. you will need make few modifications... :P
You can use it like this:
You will get:
http://www.example.com/my-super-category-cat-10
And my .htaccess of course:
Unless you think the brand names are likely to change then you want to do 2 rewrites, one as a redirect and one internal:
This means that browsers / spiders will always see the nice URLs while your application will see the real ones.