Forum Moderators: bakedjake

Message Too Old, No Replies

mod rewrite gives Unauthorized error

mod rewrite

         

Egbert Souse

1:27 am on Jul 19, 2003 (gmt 0)

10+ Year Member



I recently moved another website out of M$ FrontPage. I switched the extensions from .htm to .php

WHen I had the pages using the .htm extension I was able to view the pages.

When I deleted all the .htm pages I got an unauthorized error.

I am using a .htaccess file from another website I am administering. That website was also at one time a Fp site. It was recently changed to shtml.

I copied the .htaccess file and made the following changes.

All I did was to change the shtml to php in this file and chagne the domain to the correct domain (which is stevia-stevioside.com )

My index page on the domain is called index.php

ErrorDocument 404 /missing.php
<Files .htaccess>
order allow,deny
deny from all
</Files>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.htm$ $1 [C,E=WasHTM:yes]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=1]
RewriteCond %{ENV:WasHTM} ^yes$
#RewriteRule ^(.*)$ $1.htm
RewriteRule ^(.*)$ [example.org...] [R=301,L]

At this point I was forced to rename the .htaccess file so I and the rest of the world could get access to the site.

I called the hosting company. THey tested with a test mod rewrite htaccess That worked perfectly. It was basically a redirect to cnn. They rebooted the apache server. BUt still I was getting an unauthorized error.

I am able to ftp in with no problem. It is just that when trying to access the html pages in a browser when the .htaccess is live everyone gets the error.

Any ideas to try will be greatly appreciated.

Thanks in advance.

[edited by: littleman at 3:05 am (utc) on July 19, 2003]
[edit reason] url snip [/edit]

jdMorgan

2:51 am on Jul 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Egbert_Souse,

Welcome to WebmasterWorld [webmasterworld.com]!

What specific error code are you getting? 400, 403, or?
What happens if you request a .php file WITHOUT the .htaccess in place?

A note: Please do not post "personal" URLs at WebmasterWorld - See the TOS below.

Jim

Egbert Souse

1:20 pm on Jul 19, 2003 (gmt 0)

10+ Year Member



Hi Jim,

First, sorry about the posting of the URL. I just thought that it might be helpful. But from now on I will disguise the URL.

Here is the error I get:

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

Apache/1.3.27 Server at www.WhateverserverItIs.com Port 80

When I rename the .htaccess file [ htaccess.BAK ] so there is no active .htaccess file, I can access any php file I want.

The test mod rewrite file that was used to test if mod rewrite was working is below:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} example1.com$
RewriteCond %{REQUEST_URI} ^/
RewriteRule ^(.*) [example2.com...]

I was sent to the domain listed in example 2 when this version was active.

Any ideas why this mod rewrite works but what I hav does not?

What my goal is, is to have a visitor or search engine visit the site using the old extension [ .htm ] they get redirected to the same page with the new extension [ .php ] and they see the new page in the address bar of the browser [http://example.com/webpage.php ] is what they see, even though they entered [http://example.com/webpage.htm]

Any thoughts, ideas, or direction will be greatly appreciated.

Thank you.

jdMorgan

4:43 am on Jul 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm...

Check the file permissions on your php files. Make sure that there is no code in your .htaccess file, or any .htaccess file in directories *above* the one we're discussing, that limits access to .php-extension files. You may have to ask your web host to look into this.

It would be helpful for the host to know that answer to the question I asked above:

> What happens if you request a .php file WITHOUT the .htaccess in place?

That is, what happens if you type [yourdomain.com...] into your address bar? Do you still get a 403? In that case, it is probably some configuration problem, not your .htaccess file.

By the way, your .htaccess code is a modified version of an example in the Apache mod_rewrite documentation [httpd.apache.org], so I believe you can have a little faith in it and spend some time looking for problems elsewhere. See the example called "Backward Compatibility for YYYY to XXXX migration" in the Apache 1.3 URL Rewriting Guide [httpd.apache.org].

I hope you can resolve this soon, or get some more help; I'm leaving for vacation tomorrow, and will have very limited - if any - access to the 'net.

Best,
Jim

Egbert Souse

1:05 pm on Jul 22, 2003 (gmt 0)

10+ Year Member



Hi Jim,

I hope your vacation is relaxing and enjoyable :)

<What happens if you request a .php file WITHOUT the .htaccess in place?

That is, what happens if you type [yourdomain.com...] into your address bar? Do you still get a 403? In that case, it is probably some configuration problem, not your .htaccess file. >

When .htaccess is disabled, I get to the page
[yourdomain.com...] with no problem.

There is no additional code in my .htaccess file. There are no .htaccess files in my /home/sampledirectory

The first .htaccess file is in my:
/var/www/html

And that is the one that is not working correctly.
The permissions on the .php files is 644
The permissions on the .htaccess file is also 644

It makes no sense why this would not work.
Again, there is a test .htaccess file that is basically a mod rewrite redirect that does work.

You can see post 3 in this thread for the code. That one does work.

I'm wondering if maybe I should redo my .htaccess file in the text editor again, and then load it again and try it.

There are no spaces above the first line
ErrorDocument 404 /missing.php

Thanks for your help. Jim, you know what is going to happen. You will be lying on the beach drinking a Mai Tai and suddenly a suggestion will pop into your head.

Anyway, enjoy your vacation. Your assistance is greatly appreciated.