REALLY main mod_rewrite question

I am trying to use SEO friendly URLs for a website. The website displays information hierarchically. For example, if my site was about cars, I would like the url http://example.com/ford 'to show all the Ford models stored in my "cars" table. Then the URL http://example.com/ford/explorer will show all Ford Explorer models (V-6, V-8, Premium, etc.).

Now the question is: Is mod_rewrite used to rewrite a query string style url into a semantic url, or vice versa? In other words, when I use JavaScript to set window.location=$URL

whether the URL should be the query string version http://example.com/page.php?type=ford&model=explorer 'OR make internally use' http://example.com/ford/ explorer 'which then gives me access to query string variables?

Hopefully someone can see my confusion on this issue. For what it's worth, I have unique slugs for all of my top-level categories (obviously the site is not about cars).


Thanks for all the help. I rewrote the rewrite, but it affects other paths on the site (CSS, JavaScript, images). I am using the correct path structure for all these inclusions (eg "/images/car.png" and "/css/main.css"). Should I use an absolute path (' http://example.com/css/main.css ') for all files? Thank!

+2


source to share


2 answers


Generally, people who use mod_rewrite use terminology like this:

I want mod_rewrite to rewrite A as B.

This means that any request from the outside world for page A is rewritten to file B on the server.

You want the outside world to see URLs that look like

A) http://example.com/ford/explorer



but your web server wants them to look like

B) http://example.com/page.php?type=ford&model=explorer

I would say that you want to rewrite (A) to look like (B), or you want to rewrite the semantic url in the query string url.

Since all links on your page are clicked by the user and / or requested by the browser, you want them to look like (A). This includes the links that javascript uses in window.location. They can and should look like (A).

+3


source


after you've configured mod_rewrite

, then your links should point to the mod_rewritten version of the url (in your example: http://mysite.com/ford/explorer ). Internally in your system, you will still refer to variables as if they were traditional query string name value pairs, though.

It's also worth noting that Google is now starting to protect more logical URLs from a search engine perspective, i.e. the query string on top of mod rewrite



Does this mean that I should avoid dynamic url rewriting altogether ? This is our recommendation if overwriting is limited to deleting unnecessary parameters, or you are very diligent in removing all parameters that could cause problems. If you change your dynamic url to make it static, you must be aware that we may not be able to correctly interpret the information in all cases http://googlewebmastercentral.blogspot.com/2008/09/dynamic-urls-vs -static-urls.html

also worth a look: http://googlewebmastercentral.blogspot.com/2009/08/optimize-your-crawling-indexing.html

+2


source







All Articles