Forum Moderators: phranque

Message Too Old, No Replies

301 redirect help

301 redirect help PLEASE HELP!

         

toyartist

3:52 am on Mar 5, 2009 (gmt 0)

10+ Year Member



Hello, Im completly new to this so please just any kind of real help would be great. I have a site that i recently switched over to .php from html and didn't know about redirects so I lost all my traffic. After asking for help I was told to put a 310 redirect in my .htaccess file. I contacted godaddy, they said i would need to create a .htaccess file from scratch (well Im new I have no idea how to do that and not sure how to upload or what kind of permissions it needs) plus i have almost 200 pages to redirect and they told me to put this in the root folder(i have 20 urls on that server so wont it affect all of em? is there a way to have this file redirect all html files to php? or do i need to do them all one at a time.
the url is <snip>

Please help i am so lost with this

Thanks

[edited by: jdMorgan at 4:40 am (utc) on Mar. 5, 2009]
[edit reason] No URLs, please. See Terms of Service. [/edit]

jdMorgan

4:45 am on Mar 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The first thing I'd suggest is... Calm down.

You've got a trivially-simple project here, and it's likely that it can be solved with one line (or just a few lines) of code.

The first thing we need to know is, do you really need a redirect? You could just simply keep *linking* to .html URLs, but *serve* .php files when .html URLs are requested. The advantage is that none of your inbound links need to change, old bookmarks will still work, and search engines will see no difference in your site unless you changed the content of pages or their URL/names (other than changing .html to .php, that is).

What do you want to do?

Jim

toyartist

4:54 am on Mar 5, 2009 (gmt 0)

10+ Year Member



thanks Im breathing again LOL ok i don't want to sound stupid, but i have removed all the index.html and any other files already, so i just need for outside links to go to the index.php or just php file (does that make sense?) google is looking for those .html files and so are some of my inbound links. so is a redirect needed? I really don't know i need to leave this in much more experienced hands in this case you :) what do you suggest?

toyartist

4:56 am on Mar 5, 2009 (gmt 0)

10+ Year Member



oh the pages are updated very often well the content anyway, will that make a difference?

jdMorgan

5:05 am on Mar 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, we are dealing here only with URLs, and the files that those URLs resolve to... Note that we make this distinction; URLs are not files and files are not URLs, they are only "associated" with each other by the server (and we are going to change how that association works).

First, create a plain-text (US-ASCII or UTF-8) file on your PC named "htaccess.txt" and put this in it:


Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www.google.com/ [R=301,L]

Then upload that to your server using FTP. Put it in the root directory of the domain you mentioned (but we don't mention 'personal' domains here for many, many reasons).

Once the file is on your server rename it to ".htaccess"

Now request the page /foo.html on your site... You should end up at google. If not, report back what you see, and if you get a server error, please report the relevant contents of your server error log.

Jim

toyartist

5:12 am on Mar 5, 2009 (gmt 0)

10+ Year Member



I get a 500 internal server error on all my pages now

i stopped breathing again LOL

toyartist

5:14 am on Mar 5, 2009 (gmt 0)

10+ Year Member



Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, support@supportwebsite.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

jdMorgan

5:15 am on Mar 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now request the page /foo.html on your site... You should end up at google. If not, report back what you see, and if you get a server error, please report the relevant contents of your server error log.

...

toyartist

5:21 am on Mar 5, 2009 (gmt 0)

10+ Year Member



i saw that im not sure where to get the server error log- i told you im new i have zero clue where to look- thanks for being patient with me

jdMorgan

5:29 am on Mar 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't tell you -- It depends on where your host likes to put log files. Either dig around for it, or ask your host. It is usually co-located with your raw server access log, and may be in a directory-path "near" your "stats" report.

Jim

toyartist

5:44 am on Mar 5, 2009 (gmt 0)

10+ Year Member



i found stats, but cant find error log anywhere, Im so in over my head

toyartist

3:37 pm on Mar 5, 2009 (gmt 0)

10+ Year Member



I have an email into godaddy to find the server error log I will check back with you when i get this info Thanks.

Paul

toyartist

3:39 am on Mar 6, 2009 (gmt 0)

10+ Year Member



ok i have found the log do you want all of the info listed in there?

jdMorgan

4:06 am on Mar 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, only the one or two lines from your error log related to the 500 server error you get when testing (look for the appropriate timestamp and for your own IP address in these log entries).

Also, please post the one or several entries from your access log that correspond to the same time as those in the error log.

Jim

toyartist

4:13 am on Mar 6, 2009 (gmt 0)

10+ Year Member



ok i have tried many times tonight to repeat the 500 error and cannot it is now a missing page error 404

toyartist

4:15 am on Mar 6, 2009 (gmt 0)

10+ Year Member



the 404 was for the foo.html page the rest of the site looked fine

jdMorgan

4:18 am on Mar 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So the code is not installed in the right file in the right place, or is not executing. I suggest you go back to my second post, and check all the "details".

Jim

toyartist

4:19 am on Mar 6, 2009 (gmt 0)

10+ Year Member



[Thu Mar 5 20:57:27 2009] [error] [client 66.251.242.185] File does not exist: /var/chroot/home/content/s/c/i/#*$!#*$!xx/html/myurl/missing.html

that was the error i changed the url and personal stuff

toyartist

4:23 am on Mar 6, 2009 (gmt 0)

10+ Year Member



I have gone over your details agin same 404 error. do i need to set permissions?

toyartist

5:18 am on Mar 6, 2009 (gmt 0)

10+ Year Member



[Thu Mar 5 22:16:13 2009] [alert] [client 70.180.231.82] /var/chroot/home/content/s/c/i/#*$!#*$!#*$!X/html/myurl/.htaccess: Invalid command '\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1', perhaps mis-spelled or defined by a module not included in the server configuration

ok the 500 error is back here is the error code

Im really confused now

jdMorgan

2:19 pm on Mar 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Missed this, apparently:

First, create a plain-text (US-ASCII or UTF-8) file

You have added non-ASCII hex-encoded text to your .htaccess file, and Apache can't handle it.

Use only Windows Notepad or a similar "ASCII editor" to edit your .htaccess file.

Jim

toyartist

2:56 pm on Mar 6, 2009 (gmt 0)

10+ Year Member



Thanks again for your help with this, I am on a mac using or i guess trying microsoft word and have also tried text edit they are the only text editing programs i have and I have tried every combo i can think of as far as saving these files as you asked. word doesnt seam to have the option to do more then a .doc or .txt file, but doesnt say what kind it is saving (ie ascii or utf-8) text edit is saving in utf-8 plain text, but still giving me the 404 error. Im off to work Ill be back later tonight. what time zone are you in?

Paul

jdMorgan

3:03 pm on Mar 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Microsoft Word is most certainly *not* a text editor -- It is a word processor. Don't attempt to use it for anything having to do with Apache...

Macs come with a plain-text editor -- Try a few searches to get its correct name, as I'm not sure what it is.

Jim

toyartist

5:24 am on Mar 7, 2009 (gmt 0)

10+ Year Member



[Fri Mar 6 22:16:23 2009] [error] [client 70.180.231.82] File does not exist: /var/chroot/home/content/s/c/i/sciaccacasper/html/example/foo.html
[Fri Mar 6 22:16:23 2009] [error] [client 70.180.231.82] File does not exist: /var/chroot/home/content/s/c/i/sciaccacasper/html/example/missing.html

Hi Jim I can't believe that something like this could be so hard to do I have used textedit in almost every possible combination from ascii to utf-8 have tried every way to up loaded it and all i keep getting are those 2 codes you see above. I just dont know what to do Please help

[edited by: jdMorgan at 10:29 pm (utc) on Mar. 8, 2009]
[edit reason] example.com [/edit]

toyartist

5:34 am on Mar 7, 2009 (gmt 0)

10+ Year Member



[google.com...]

OK Im sorry I got it now it sent me to that page in google above Im liking it, what is next?

toyartist

4:21 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



Hello

I have changed your code to redirect my index.html page back to http://www.example.com/ and it works well, but now i need to redirect all of the index.html pages in all of the folder back to their main folders as well.

ex. from http://www.example.com/folder/index.html
to http://www.example.com/folder/

how can i do that i have dozens of these folders all used to have index.html now contain index.php

is there a way to do them all from that one .htaccess page or should i place an .htaccess page in each folder?

Im not sure how it work. Help Thanks

[edited by: jdMorgan at 10:27 pm (utc) on Mar. 8, 2009]
[edit reason] example.com [/edit]

g1smd

5:01 pm on Mar 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's plenty of examples for index files in all folders to redirect. Just two lines of code will do it.

[google.com...]

toyartist

5:07 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



thanks for the link i will check it out, but i am completely new to .htaccess and have really no idea what im doing so i may come back with more questions

thanks

g1smd

5:21 pm on Mar 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The best way to learn this stuff is to set up a password protected (so search engines cannot access it, let alone index it) test or dev sub-domain, or set up Apache on your PC.

For a local PC copy, enter some invented hostnames in the HOSTS file (so that they will resolve to your local copy of Apache) and then try things out.

Never experiment with a live site in case you fatally break something while searchengines are indexing it.

toyartist

5:39 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



Thanks for the advise, I have been building sites for years now and have never had to do anything think this, but now Im seeing it is quite common. So I will need to learn.

My site that Im trying to fix was set up with all index.html pages and one or 2 folders even contain index.html index2.html etc now everything on the site is .php so i think this code i found on your link may take care of some of it, what do you think?

Directoryindex index.html
#
# redirect all <subdirectory>/index.html requests to <subdirectory>/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.com/$1 [R=301,L]

does<subdirectory> need to be named? iI have dozens of sub folders

right now Im using this code Jim gave me

Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^index\.html$ http://www.example.com/ [R=301,L]

and it is properly resending anyone who trys to call the doamin via the index.html page over to the new index.php

the only problem is that it isn't writen to do sub directories and it is sending everyone back to one page and not to the subdirectory itself (does that make any sense?)

as to setting up a password? Again I have no idea, if google indexes it, is that bad?

I am really new please excuse me if these questions are in any way dumb

thanks,
Paul

[edited by: jdMorgan at 1:17 pm (utc) on Mar. 10, 2009]
[edit reason] RewriteCond pattern corrected as noted below. [/edit]

This 56 message thread spans 2 pages: 56