Forum Moderators: phranque

Message Too Old, No Replies

"Forbidden" when changing .htaccess

when I change my .htaccess, I get a "Forbidden" message.

         

BruceCH

1:11 am on Feb 12, 2005 (gmt 0)

10+ Year Member



I just finished converting a site from Frames to XHTML. All of the default pages with a filetype of html have been replaced with a page with a filetype of shtml. But there are several hundred pages! (yes, they are create via script!)

My problem is that many of these html pages are linked to by our customers. I don't want to have to break the links by deleting the pages and have our customers drill back through our site to find the new page. I thought that I should be able to create a ReWrite rule that would do that for me. I came up with:

RewriteEngine on
RewriteRule ^(.*)/default.html$ $1/default.shtml
ErrorDocument 404 [mysite.com...]

But when I upload it I get a "You don't have permission to access /mypage.shtml on this server." message when I go to www.mysite.com/mypage.shtml. What am I doing wrong?

jdMorgan

2:27 am on Feb 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



BruceCH,

Welcome to WebmasterWorld!

Easy stuff first...
This is incorrect:


ErrorDocument 404 http://www.mysite.com/404.html

In order to return a proper 404 response, you must use a local URL-path. See the ErrorDocument documentation in Apache core. Instead, use:

ErrorDocument 404 /404.html

You rule will never match on a request for default.html in the home directory. To do that, you'll need to change it to:

RewriteEngine on
RewriteRule ^(.+/)?default\.html$ $1default.shtml [L]

If you are still getting 403 errors, I'd suggest checking the Unix file permissions of your .shtml files. Set them to 644 and see if that helps.

Jim

BruceCH

11:13 pm on Feb 12, 2005 (gmt 0)

10+ Year Member



Thanks for the pointer on the 404.

All of the files are set to 644 (html and shtml), but I still get the error. Any other suggestions out there?

BruceCH

3:06 am on Mar 1, 2005 (gmt 0)

10+ Year Member



I checked with my hosting company and discovered that I was the first person on that server to request Mod_rewrite, so it hadn't been turned on yet! They turned it on and all of the .html pages are now redirected to .shtml version.

However, none of my cgi-bin programs work when the .htaccess file is active. I get the same "Forbidden" message as before.

I feel I'm closer, but I just don't see why the scripts wouldn't work. Their path is different than the other pages.