Howto redirect or forward a link / url via .htaccess

If you want to redirect / forward a link / url the easiest solution is to use a .htaccess file. You need to place it in the directory where the user would normally land with the original link.

The general structure is simple. You´ll only need to enter one single line in the .htaccess file:

Redirect permanent old location new location

  • old location must be a relative link to root of your server structure, e.g. /wwwroot/index.html
  • new location must be a full link, e.g.  http://www.yoursite.de/index.html

So in case you want to redirect http://www.mysite.com/index.html to http://www.my-new-site.com/index.html your .htaccess file needs to be placed in the same directory where the index.html is and should look like this:

Redirect permanent /wwwroot/index.html http://www.my-new-site.com/index.html

If you want to redirect something like this http://www.mysite.com/uploads/12/myuploadedfile.rar to this new location http://www.my-new-site.com/download/myuploadedfile.rar then your .htaccess file needs to be placed in the “12” directory and should look like this:

Redirect permanent /wwwroot/uploads/12/myuploadedfile.rar http://www.my-new-site.com/download/myuploadedfile.rar

Remember: The /wwwroot/ can be different on your site / server. You need to find out the webservers document root. A common directory is also /public_html/.

Thx to the RBI @ Uni Frankfurt – see their site for more information about url redirecting (only in german).

 

The uploaded file could not be moved to – WordPress 3.3.1

Update – 25.01.2012

I still haven´t found a good solution for the problem. Several people report that they were able to solve it , by changing the owner of the “uploads” directory (to the user which php runs as (in most cases “wwwrun”). But that didn´t worked for me. The only solution I found was to run php as FastCGI and not as an Apache module. This solution though has some drawbacks. You need to configure a single php.ini for every virtual host you run and you can´t use .htaccess files anymore.

My conlusion – FastCGI resolves the problem but doesn´t cure the root of all that evil.

I guess the WordPress 3.3 and 3.3.1 are the worst releases the WordPress Team ever did. First the fucked up the visual editor and now the shittiest WordPress problem ever: “The uploaded file could not be moved to” – a problem occuring when you try to upload images/videos/media (and when your php runs in safe mode).

In older WordPress versions it could be easily solved by chmod 777 the “uploads” folder within “wp-content”. Now this doesn´t work anymore.

One solution is to chmod 777 “wp-content” completely. But they can´t be serious about that…can they ?