Help redirecting bad links.

amvarchitecture

New Member
Messages
16
Reaction score
0
Points
0
The problem with my site, is that I change the name of homepage quite a bit, which means that the link changes. The problem is that people bookmark my site, and then when they want to go back to the website, the page they bookmarked no longer exists, so they get an invalid link. Is there a way to make it so anything typed after the .com will just redirect to my site, which would redirect to my home page?

Thanks A LOT in advance for any help.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
In .htaccess in public_html add :


Code:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ /  [R=301,L]

This will redirect them to the new homepage and put yoursite.com/ in the address bar.
You can use /newhomepage.php (or whatever name it has) instead of /

This assumes you have added somenewhomepage.htm (or whatever) as the index page in .htaccess via

DirectoryIndex somenewhomepage.htm index.php index.html
 
Last edited:

amvarchitecture

New Member
Messages
16
Reaction score
0
Points
0
Could you please try to simplify what you said? You lost me. I attached a screenshot of the public HTML folder where all of my website files are.

Which file do I alter?

Screenshot2009-11-12at91752PM.png
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Close FileManager
Bottom of cPanel page find and click on link that says "reset all interface settings"
Click on FileManager icon
You should get a File Manager Directory Selection Dialog
Click on "Show Hidden Files (dotfiles)" checkbox
--and if you want, the "Skip this question" box too
Click "Go"
The FileManager should appear and you should be able to see .htaccess as the first file after your direcories.
If it is still not there, create it with "New File".
 

playminigames

New Member
Messages
216
Reaction score
6
Points
0
before you go into the file manager you have to allow it to show hidden files, then do what descalzo said. Good luck!

ha ha descalzo you beat me :)
 
Last edited:

balaji2u

New Member
Messages
410
Reaction score
2
Points
0
If you didnt find show hidden files option,just click index.html and choose edit file then in File Edit window you will see the path of the file at the top left something like
/home/username/public_html/index.html change it to /home/username/public_html/.htaccess and click OPEN
now add the code which dezcalzo gave above.
Good Luck. :)
 
Top