I read Jim's reply: I concur with the sentiment and the advice, but I was a little confused at first, so thought I might expand.
There are three issues to resolve.
One is getting the rewrite condition/rule to capture and redirect externally ("R=301") the response to a URL that looks as you want, but returns the proper page. If you do a 301 redirect, the browser will not return the page, but instead will return a new URL (the pretty one) that the browser will request again in a second try. Assuming your site knows how to return a page using that new URL format (see below), the second response will result in a page the user can see.
And a 301 redirect as described
will change the URL displayed in the address bar, and will cause search engines to eventually change what they use as links to your site. However, it's only part of the problem.
You must also make sure that your website knows how to respond properly to the new URL format once it comes in. If you do not want to change anything in your site, then an internal rewrite from the new (external) URL format to the existing (internal) URL format is an option.
However, you may want to consider whether there's an alternative to an internal, since (as Jim points out), there's one more issue.
The last is making sure that the pages with links to other pages on your site start returning those URL links in the new format. Without doing this, every click on your site to an old-style URL will result in a 301 redirect, which is pointless, time-consuming and poor practice.
I would have a slight disagreement with Jim's phasing "You must stop the old/incorrect links..." -- I would change "must" to "should" because even if it's terrible practice to produce links in your pages that are different than the ones you want users and search engines to see, as long as you address the first two items, the site will work ... technically.
It will take a long time (months, years?) for all the links to your site out on the web to get updated, so you have to support both old and new formats when the request is received, but if you're already changing the way the links in your site are presented, maybe you can also change how the site responds to URL requests in the first place. Internal rewrites have a couple tricky aspects that have tripped up many (like me).
As for the CSS, you'll need to make sure your conditions know how to handle that case as well -- another reason to see if you can change the way the site generates and responds to URLs in the first place.
So some additional questions for you:
- How are your pages being generated now? Are you using software like WordPress, Blogger, Drupal, etc. or a custom php program. If the former, check to see if the software has some means of handling this kind of URL transformation, sometimes known as "pretty URLs" or similar. Wordpress allows this (almost) automatically, for example.
- You can add rewriting directives in two different contexts. If you have access to the web server configuration files, you can do all of this in a
<VirtualHost>
container. In either case, you can also do these in a .htaccess file, typically located in the document root of your site. There are subtle but important distinctions between how they work, so please specify which option(s) are available to you.
- If your current publishing software doesn't allow pretty URLs or you cannot change the scripts, are you sure you need to do this change? Or could you just move the site to another platform that allows such a change?
- Some examples of specific URLs in old and new format would help. If you surround them with the "code", "url", or "pre" style codes the URLs won't get mangled by the forum software. See the link for Style Codes for more info.
Hopefully this is not confusing Jim's response, but instead amplifying the message. With this information I am sure we can do a good job of helping.
Tom