SEOClerks

How Do I Forward Page URLs After The Page Has Been Deleted?



Write the reason you're deleting this FAQ

How Do I Forward Page URLs After The Page Has Been Deleted?

How do I forward the URL of a page to the home page after I delete the page?
What i am meaning is.. I am going to delete the following page: http://www.xboxlivefan.org/adminpromotion.php, but it is linked to on several places on across the net so i want to redirect the URL to the home page rather than people getting a "Page Not Found" error or something similar. This way I still benefit from click on links to the page I delete. Can someone please reply below and let me know, Thanks! How Do I Forward Page URLs After The Page Has Been Deleted?

Comments

Please login or sign up to leave a comment

Join
karoshio
Hi Sean,

This simple snippet is hopefully what you're looking for, this is added into .htaccess.

Redirect 301 /adminpromotion.php http://www.xboxlivefan.org/otherpage.php


Basically it's just the first will redirect to the second, so if someone accessed file is first they will end up to the second URL.

Regards,
Karoshio



Are you sure you want to delete this post?

Sean101
Thanks How Do I Forward Page URLs After The Page Has Been Deleted?
In that file, can I redirect more?
Like just continue on in a list...

[HTML]

Redirect 301 /adminpromotion.php http://www.xboxlivefan.org/otherpage.php
Redirect 301 /adminpromotion.php http://www.xboxlivefan.org/otherpage.php
Redirect 301 /adminpromotion.php http://www.xboxlivefan.org/otherpage.php
Redirect 301 /adminpromotion.php http://www.xboxlivefan.org/otherpage.php

[/HTML]

But obviously not each line the same, ill change the URLs to the ones I want on each line.



How Do I Forward Page URLs After The Page Has Been Deleted?



Are you sure you want to delete this post?

Sean101
I tried doing this, but it didn't work. I added the code and also tried different ways of writing the URLs but still no joy.

Redirect 301 /adminpromotion.php http://www.xboxlivefan.org/
Redirect 301 /adminpromotion.php http://www.xboxlivefan.org/index.php
Redirect 301 http://www.xboxlivefan.org/adminpromotion.php http://www.xboxlivefan.org/
Redirect 301 http://www.xboxlivefan.org/adminpromotion.php http://www.xboxlivefan.org/index.php

Redirect /adminpromotion.php http://www.xboxlivefan.org/
Redirect /adminpromotion.php http://www.xboxlivefan.org/index.php
Redirect http://www.xboxlivefan.org/adminpromotion.php http://www.xboxlivefan.org/
Redirect http://www.xboxlivefan.org/adminpromotion.php http://www.xboxlivefan.org/index.php

None of these made the page redirect to my home page.
Also, once I do get it to work, can I delete the page / file and this will still work?



Are you sure you want to delete this post?

karoshio
Hi Sean101,

Maybe it would be worth trying it using mod_rewrite, there could be some kind of conflict within your host doing it the other way I am not aware of.


RewriteEngine On
RewriteRule ^adminpromotion\.php$ http://www.xboxlivefan.org/ [R=301,L]
 


I hope the above is correct, I get forgetful on syntax when it's been a while.

Regards,
Karoshio



Are you sure you want to delete this post?

ultimate
These tricks will work no matter what extension is active.
1) This code will redirect all your Error 404 pages to your homepage.

ErrorDocument 404 http://www.yoursite.com/pagename.html

In addition to this, I generally add a query next to it and show the users a message on homepage telling the previous page was discontinued. Also its good for your analytics.
ErrorDocument 404 http://www.yoursite.com/pagename.html?message=404


2) If you are only interested in redirecting some pages but you don't have mod_rewrite enabled or troubled.
On the top of that page paste this PHP snippet and they will be redirected to whatever page your want.
[PHP]<?php
$url= http://www.mysite.com/pagename.php;
header("Location: $url");
>[/PHP]



Are you sure you want to delete this post?

Sean101
Thanks a lot and im going to try these now and let you know how it goes How Do I Forward Page URLs After The Page Has Been Deleted?



Are you sure you want to delete this post?

Sean101
That's me done it to my affiliate store to test it out, worked fine, now any page re-directs to my home page if it doesn't exist. I didn't use the message one on this as when I done it just like this " ErrorDocument 404 http://www.lowcostseosolutions.com/ " it already shows the meesage "Oops! Your requested page was not found: But, stay here to find out the best seo service:" How Do I Forward Page URLs After The Page Has Been Deleted?

Can I ask though, this is what my .htaccess file contains now..

[HTML]# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


ErrorDocument 404 http://www.lowcostseosolutions.com/[/HTML]

Is it ok that I just added the new line at the end of the file? or should it be in a specific place?



Are you sure you want to delete this post?

ultimate

[HTML]ErrorDocument 404 http://www.lowcostseosolutions.com/[/HTML]
Is it ok that I just added the new line at the end of the file? or should it be in a specific place?

I suggest using the IF_Wrapper
<IfModule !mod_rewrite.c>
    # Without mod_rewrite, route 404's to index page.
   ErrorDocument 404 /index.php
</IfModule>



Are you sure you want to delete this post?

Sean101
So the whole file to look like this? ..

[HTML]# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


<IfModule !mod_rewrite.c>
ErrorDocument 404 http://www.lowcostseosolutions.com/
</IfModule>

[/HTML]


Update..
Infact, like this would be better? ..

[HTML]# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
ErrorDocument 404 http://www.lowcostseosolutions.com/
</IfModule>
# END WordPress[/HTML]



Are you sure you want to delete this post?

ultimate
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

This already tells the web server to redirect all requests for a non existing file to the main script /index.php. But, that is possible only if your mod_rewrite module is enabled.
<IfModule !mod_rewrite.c>
ErrorDocument 404 http://www.lowcostseosolutions.com/
</IfModule>

This is a fallback logic. This will work only if your mod_rewrite is disabled or does not exist.

Anyway, for WordPress, plenty of plugins exist for stuffs like redirects. And, I would not recommend playing with the .htaccess of WordPress, it will make the site very unstable.



Are you sure you want to delete this post?