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]

g1smd

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

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



The two line code snippet (above) works for all folders on your site, at any level. You don't need to name or do anything. That's the power of the
([^/]+/)*
pattern in the code.

The password protection on your test site is very important. You don't want Google indexing and ranking those pages (duplicates, test pages, experiments), so keep all search engines out.

toyartist

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

10+ Year Member



Hello again i tried that code
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]

and it gives me 404 on the main url and all subdirectories
if i use http://www.example.com/index.php i do get the correct page, but any http://www.example.com or with a subdirectory/ i get the 404

where am i going wrong?

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

toyartist

8:29 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



Sorry its a 403

Forbidden
You don't have permission to access / on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

g1smd

8:52 pm on Mar 8, 2009 (gmt 0)

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



Are your index files named as index.html or index.php ?

If .php then change the references in the both redirect and the DirectoryIndex directive.

toyartist

8:53 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



my files used to be named index.html but are now .php

other sites are still looking for the index.html thats why i need the .htaccess

toyartist

9:15 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



ok i changed it to .php on both the redirects and the Directoryindex but its still not working the right way.

If i try to call a index.html it gives me a 404 but if i call a inex.php its fine and just a subdirectory/ is fine

i need to redirect any .html called paged to the folder/ so the new index.php pages can be found

does that make any sense (im so confused)(help)

g1smd

9:20 pm on Mar 8, 2009 (gmt 0)

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



Oh, I understand now. There's one more step.

DirectoryIndex
should list the real filename where the content resides.

To redirect both index.html and index.php to / for both root and for folders, change the \.html or the \.php to this:

\.(html?如hp[45]?吆aj]spx?)
or similar.

That will redirect all of the index URLs to strip off the filename leaving the URL to end the folder name with a trailing slash.

.

If you need to also redirect other .html URLs back to the folder level, you'll need a separate rule for that too. This one will need to allow a wildcard for the filename and have just .html for the allowed extension in the pattern.

toyartist

9:42 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



Im doing something wrong still please be patient

this it what i up loaded

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

and if i try to get folder/index.html i still get a 404 instead of being redirected back to the folder/

im so lost

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

g1smd

9:59 pm on Mar 8, 2009 (gmt 0)

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



Make sure you replace the ¦ characters with real (solid) pipe symbols - posting in the forum changes them to the wrong one.

The change of code in place of \.html needs to go in both lines - both the condition and the rule.

toyartist

10:10 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



is that what you were talking about?

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

im still getting 404 s with this when i try http://www.example.com/index.html or http://www.example.com/folder/index.html

if i use index.php i get the page

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

jdMorgan

10:25 pm on Mar 8, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That code looks fine. Look elsewhere for the problem. Specifically, look at your server error log. Anything else is just guessing.

Jim

toyartist

11:23 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



ok it looks like my problem is comming from the text file it self.

Ive tried it sevral ways on the make in textedit and had it work one time. i cant seam to duplicate it.

so i went to a friends house to try his pc using notepad and clasic ftp and still can't get the first code working

I must really be doing something majorly wrong

any idea's

please help thanks

paul

g1smd

11:26 pm on Mar 8, 2009 (gmt 0)

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



There's no way to guess this stuff. We don't know the rest of your server set up. We don't know what error messages are in the error log.

toyartist

11:44 pm on Mar 8, 2009 (gmt 0)

10+ Year Member



[Sun Mar 8 16:20:00 2009] [error] [client 70.180.231.82] File does not exist: /var/chroot/home/content/s/c/i/mmm#*$!mmmm/html/mydomain/foo.html
[Sun Mar 8 16:20:00 2009] [error] [client 70.180.231.82] File does not exist: /var/chroot/home/content/s/c/i/mmm#*$!mmmm/html/mydomain/missing.html
[Sun Mar 8 16:20:01 2009] [error] [client 70.180.231.82] File does not exist: /var/chroot/home/content/s/c/i/mmm#*$!mmmm/html/mydomain/foo.html
[Sun Mar 8 16:20:01 2009] [error] [client 70.180.231.82] File does not exist: /var/chroot/home/content/s/c/i/mmm#*$!mmmm/html/mydomain/missing.html
[Sun Mar 8 16:24:50 2009] [error] [client 72.30.79.119] File does not exist: /var/chroot/home/content/s/c/i/mmm#*$!mmmm/html/mydomain/robots.txt
[Sun Mar 8 16:24:50 2009] [error] [client 72.30.79.119] File does not exist: /var/chroot/home/content/s/c/i/mmm#*$!mmmm/html/mydomain/missing.html

those are my last errors im using godaddy to host its a linex(is that spelled right) server

im sorry to keep bothering you guys, but i really dont know where else to turn for this

Paul

toyartist

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

10+ Year Member



ok i seam to have the upload problem solved or at least for now. I have gotten your original to work again it was a combination of saving the file correctly and uploading it correctly.

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

that one is working

this one Im not sure about

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

that one being i really don't know what the script should do Im not sure its working

if i type http://www.example.com or http://www.example.com/ or even http://www.example.com/index.php i get the correct page how ever if i type http://www.example.com/index.html i get a 404 i want it to go back to the root or the folders root

will that code do it?
Paul

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

g1smd

12:36 am on Mar 9, 2009 (gmt 0)

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



Use the Live HTTP Headers extension for Firefox to see the HTTP response code sent back for this failing request.

Are there any intermediate codes sent back before the 404, or is the 404 in the very first response?

You'll also likely need to remove the / highlighted here:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*[b]/[/b]index\.(html?如hp[45]?吆aj]spx?)\ HTTP/

[edited by: jdMorgan at 1:21 pm (utc) on Mar. 10, 2009]
[edit reason] This is the correction to code posted above. [/edit]

toyartist

12:47 am on Mar 9, 2009 (gmt 0)

10+ Year Member



*/index are you talking about removing the / after the * and before index? it doesnt seam to be highlighted

404 is the first

do you mean foxfires error console? i dont see anything labeled Live http headers

jdMorgan

1:25 am on Mar 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well-spotted!

You will *definitely* need to remove that slash!

Jim

jdMorgan

1:28 am on Mar 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



remove the slash immediately preceding "index":

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)[b]*/i[/b]ndex\.(html?如hp[45]?吆aj]spx?)\ HTTP/

- should be -
 RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?如hp[45]?吆aj]spx?)\ HTTP/

The "([^/]+/)*" pattern preceding "index" will account for trailing slashes on any/all preceding directory levels.

Jim

[edit] Clarification of correction noted above. [/edit]

[edited by: jdMorgan at 1:23 pm (utc) on Mar. 10, 2009]

toyartist

2:04 am on Mar 9, 2009 (gmt 0)

10+ Year Member



Well I removed it and it didnt make any difference at all. I still get the 404 and no other errors from the error log.

I am confused as to why one code would work but this one seams to do nothing at all.

Am I Missing something on the .htaccess page?

Directoryindex index.php
#
# redirect all <subdirectory>/index.html requests to <subdirectory>/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?如hp[45]?吆aj]spx?)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(html?如hp[45]?吆aj]spx?)$ [my-url.com.com...] [R=301,L]

thats everything on the whole .htaccess

g1smd

2:13 am on Mar 9, 2009 (gmt 0)

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



I am using that exact code (except for domain name change) on at least several dozen sites and it works just fine.

Make sure you change the ¦ pipe ¦ symbols back to be solid pipes (not the broken ones shown in the forum).

Flush your browser cache before testing. The cache will still contain the old error page.

toyartist

5:31 am on Mar 9, 2009 (gmt 0)

10+ Year Member



Is there another way to do this? I know your script is working for you, but for me, not so much. Is there anything wrong with placing a redirect in each of the folders? the very first script Jim gave me works just fine, if i placed it in each folder redirecting to the folders root would that fix my problem? I cant afford to spend another week trying to fix what everyone is telling me is a simple problem its making me feel like a real idiot and Im still sinking in google i think in the last few days ive lost all my traffic.

What can I do?

toyartist

8:30 pm on Mar 9, 2009 (gmt 0)

10+ Year Member



I know you guys are crazy busy and I really do Thank you for your help so far, Today i have tried everything all over from scratch with the same results, the first code works every time the second one doesn't seam to work at all. I really don't know what to do

Please help!

Paul

g1smd

9:47 am on Mar 10, 2009 (gmt 0)

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



What response codes do you see reported in the Live HTTP Headers extension for Firefox, and for what test URLs (use example.com here)?

jdMorgan

1:25 pm on Mar 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thats everything on the whole .htaccess

I note that the "RewriteEngine on" directive is missing, and "Options +FollowSymLinks" may also be required.

Jim

g1smd

2:08 pm on Mar 20, 2009 (gmt 0)

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



Did you get this fixed?
This 56 message thread spans 2 pages: 56