Web Design and Development
A powerful tool for any web developer, .htaccess files can be used for everything from authenticating users to compressing files. But one of the most common uses of .htaccess files is for redirecting traffic and pagerank from one webpage to another. (See our article, 301 Redirects with .htaccess Files on Linux Apache, for more information.)
In the most basic case where an old page is redirected to a new page, you would set up the redirect rule as shown in the example below.
Redirect 301 /oldpage.html http://www.example.com/newpage.html
If the old or new page name contains spaces, the redirect example above will not work. Leaving spaces in the url will likely result in a 500 Internal Server Error. And if you encode the url, replacing the spaces with
, you will find that the redirect rule does not work at all. Fortunately, there is an easy solution.
Use Quotation Marks. If you enclose the url that contains spaces in quotation marks, the htaccess redirect rule will work and you won't get any server errors. See the example below.
Redirect 301 "/old page.html" "http://www.example.com/new page.html"
And that's it!Tags: error pages, htaccess file, Linux, page, redirects, search engines