I currently have a site with multiple PR4 and PR3 pages that are located in a subfolder www.domain.com/site/blog/ . How can I redirect all files to www.domain.com/
Thank you. I tried redirect, the problem with that is that all files have to moved to the new location. How is it possible to do this (modrewrite?) and not have to moved all the files, so that PR stays 4?
In a domain.com/site/blog/.htaccess file, put: Options +FollowSymLinks RewriteEngine On RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] Code (markup):
It should work with files. Try this htttp;//xyz.tld/path/xy.html and you should get it redirected to htttp;//xyz.tld/xy.html.
@rodney88 I had tried that, but its does nothing for me. It only works when I also add rewriteCond %{HTTP_HOST} !^www\.domain\.com to make sure the www is automaticly added. @abdussamad The problem is that I do not want to copy all the files from the old folder to the main root folder. This is because the CMS only recodnizez the files when they are in the site/blog folder.
Eh? By the very definition of a condition, it's impossible to force a rewriterule to apply by adding a rewritecond. Do you mean you already have other rewrites in place? If so, it would be helpful if you posted the rest of the codes.
This is how my current .htaccess looks like Options +Indexes Options +FollowSymlinks RewriteEngine on # Redirect to WWW rewriteCond %{HTTP_HOST} !^www\.domain\.com rewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301] Code (markup):
And where is that file? I assume in the root of your domain so that you redirect everything to www? You have two choices - if you want to put it in the root, you need to set the paths to only redirect the correct folder: RewriteRule ^site/blog/(.*)$ http://www.domain.com/$1 [R=301,L] Code (markup): If you put an .htaccess in the /site/blog/ folder itself, use the code previously posted.
The .htacess file is in the root. When I try the above code, I get a 404 error. Do I need to copy all the files from the site/blog folder to the root folder? If so, is it possible to have a moderewrite without copying the files? Otherwise the CMS gets messed up.
All this does is (as asked for in OP) redirect www.domain.com/site/blog/* to www.domain.com/*. If you haven't actually moved the files, yes you will need to do an internal rewrite back the other way. (Although if you haven't moved it, the whole exercise seems a little pointless) domain.com/.htaccess # Setup rewriting Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / # Redirect old /site/blog requests RewriteRule ^site/blog/(.*)$ http://www.domain.com/$1 [R=301,L] # Force WWW RewriteCond %{HTTP_HOST} !^www\.domain\.com RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301] # Rewrite / back to /site/blog RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ site/blog/$1 [L] Code (markup):
If you're already indexed, there's not much to be gained by moving it all around. You're sending a 301 redirect that takes a valid request and sends it to the root of the domain, only to have to rewrite everything back to its original location anyway.