I have read tons of 301 redirect threads but i just can not get it to work how i want it too? I know its taking note of the .htaccess file because different code/301's i have added create different results. I have hundreds of pages on my site ... im closing it down in 6 months and trading on a different domain. What i want to do is make ANY visitors to my site get 301 redirected to within my old site so that they see a holding page explaining whats happening? So i want all files at www.mysite .com to redirect to index.php I have tried so many different ways and i get things like ... Visitor opens www.mysite .com/blue.php and it redirects to index.php but the url does not change? Another time i have added code and i get internal server errors. Another time it seems that its trying to redirect but it keeps loading the page? Man i need a drink.
RewriteEngine on RewriteCond %{HTTP_HOST} ^yoursite.com [NC] RewriteRule ^(.*)$ http://www.yournewsite.com/index.php [L,R=301] Code (markup): Or if you want them to go to the same page on the new site: RewriteEngine on RewriteCond %{HTTP_HOST} ^yoursite.com [NC] RewriteRule ^(.*)$ http://www.yournewsite.com/$1 [L,R=301] Code (markup):
hmm... but before setting-up the codes for .htaccess, have you tried to ask your host if the mod_rewrite module of Apache is Activated?
Hi, I have just tried the first section of code and this has no effect? i can still visit any pages on the site without it returning me to the home page?
As I have said before, have you tried asking your Systems Administrator if mod_rewrite module is activated for your server? Because if it is not, then none of the .htaccess code will work.
Just as a follow up, any directory in which you have a .htaccess file must have AllowOverride FileInfo Code (markup): at the very least in order to allow rewrites. Of course, mod_rewrite must also be installed, and the server must be apache. IIS Servers have their own version of mod_rewrite that's an ISAPI plugin but I have no idea what it is called.