logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Why Apache returns 403 ?
Author
Rocker



Joined: 26 Feb 2012
Posts: 16
Location: Brazil

PostPosted: Thu 01 Mar '12 20:10    Post subject: Why Apache returns 403 ? Reply with quote

Hi, all


I started with Apache not long ago, so I don't know if that's normal or not...


Enabling mod_rewrite, and forcing "www", when I request "www.example.com/:", Apache returns 403.
But, when I request "example.com/:", Apache redirets to my ErrorDocument page ("/errors/403.htm").


In other words:

Request [www.example.com/:] = Don't redirect, only show 403 on page.

Request [example.com/:] = Redirects to [www.example.com/errors/403.html]




1nd: Why Apache redirects to my ErrorDoc 403 page when I request a page without "www" ??? Is this a bug?
2st: Why Apache returns 403 when I request "/:" ?



Thanks in advance
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7304
Location: Germany, Next to Hamburg

PostPosted: Thu 01 Mar '12 23:53    Post subject: Reply with quote

Does the 403 happen without the rewriting?
You may post your rewrite rules you use Wink
Back to top
Rocker



Joined: 26 Feb 2012
Posts: 16
Location: Brazil

PostPosted: Fri 02 Mar '12 0:10    Post subject: Reply with quote

Thanks for your interest


Yes, to request /: returns 403, even with mod_rewrite disabled...


My .htaccess (I use it because httpd.conf requires Apache to be restarted after every modification):

Code:
<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteBase /

    RewriteCond %{HTTP_HOST} !^www\.site\.dev
    RewriteRule ^ http://www.site.dev%{REQUEST_URI} [R=301]

    RewriteRule "robots.txt" ".robots.php"
    RewriteRule "sitemap.xml" ".sitemap.php"
    RewriteRule "captcha.png" ".captcha.php"

    RedirectMatch 404 ^/.ht
    RedirectMatch 404 \.lib\.php$
    RedirectMatch 404 /captcha/
    RedirectMatch 404 /xml/

</IfModule>


My "hosts" file:
Code:
127.0.0.1       localhost

127.0.0.1       site.dev
127.0.0.1       www.site.dev



ErrorDocuments (httpd.conf)
Code:
# ErrorDocument specificatinos
#
#   4xx - Client Error
ErrorDocument 400 /http-errors/400.html
ErrorDocument 401 /http-errors/401.html
ErrorDocument 402 /http-errors/402.html
ErrorDocument 403 /http-errors/403.html
ErrorDocument 404 /http-errors/404.html
ErrorDocument 405 /http-errors/405.html
ErrorDocument 406 /http-errors/406.html
ErrorDocument 407 /http-errors/407.html
ErrorDocument 408 /http-errors/408.html
ErrorDocument 409 /http-errors/409.html
ErrorDocument 410 /http-errors/410.html
ErrorDocument 411 /http-errors/411.html
ErrorDocument 412 /http-errors/412.html
ErrorDocument 413 /http-errors/413.html
ErrorDocument 414 /http-errors/414.html
ErrorDocument 415 /http-errors/415.html
ErrorDocument 416 /http-errors/416.html
ErrorDocument 417 /http-errors/417.html
ErrorDocument 422 /http-errors/422.html
ErrorDocument 423 /http-errors/423.html
ErrorDocument 424 /http-errors/424.html
ErrorDocument 425 /http-errors/425.html
ErrorDocument 426 /http-errors/426.html
#ErrorDocument 428 /http-errors/428.html
#ErrorDocument 429 /http-errors/429.html
#ErrorDocument 431 /http-errors/431.html
#ErrorDocument 444 /http-errors/444.html
#ErrorDocument 499 /http-errors/499.html
#
#   5xx - Server Error
ErrorDocument 500 /http-errors/500.html
ErrorDocument 501 /http-errors/501.html
ErrorDocument 502 /http-errors/502.html
ErrorDocument 503 /http-errors/503.html
ErrorDocument 504 /http-errors/504.html
ErrorDocument 505 /http-errors/505.html
ErrorDocument 506 /http-errors/506.html
ErrorDocument 507 /http-errors/507.html
ErrorDocument 508 /http-errors/508.html
ErrorDocument 509 /http-errors/509.html
ErrorDocument 510 /http-errors/510.html
#ErrorDocument 511 /http-errors/511.html
Back to top
Rocker



Joined: 26 Feb 2012
Posts: 16
Location: Brazil

PostPosted: Fri 02 Mar '12 0:28    Post subject: Reply with quote

And about the rule forcing "www",

I tried all these, all of them works, but all of them have the same problem ("/:" = 403)...
(I'm running the first one, but I tested all.)


#01
Code:
RewriteCond %{HTTP_HOST} !^www\.site\.dev
RewriteRule ^ http://www.site.dev%{REQUEST_URI} [R=301]


#02
Code:
RewriteCond %{HTTP_HOST} ^site\.dev
RewriteRule ^ http://www.site.dev%{REQUEST_URI} [R=301]


#03
Code:
RewriteCond %{HTTP_HOST} !^www\.site\.dev
RewriteRule ^(.*)$ http://www.site.dev/$1 [R=301]


#04
Code:
RewriteCond %{HTTP_HOST} ^site\.dev
RewriteRule ^(.*)$ http://www.site.dev/$1 [R=301]
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7304
Location: Germany, Next to Hamburg

PostPosted: Sat 03 Mar '12 12:46    Post subject: Reply with quote

At least, you should making the "is there a www" rule the last one with the L parameter. I also recommend to comment out the other rules to make sure this works for you.

Code:

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !^www\.site\.dev$ [NC]
RewriteRule ^(.*)$ http://www.site.dev/$1 [R=301,L]
Back to top
Rocker



Joined: 26 Feb 2012
Posts: 16
Location: Brazil

PostPosted: Sun 04 Mar '12 17:16    Post subject: Reply with quote

Ok, I done that, but, what is [L] ?

----------

I commented out all that lines and /: keeps returning 403.

----------

OBS: I have a friend with Apache 2.2 + PHP 5.3.5 VC6 running on Windows 7.
And his Apache returns 403 when requesting /:, like mine.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7304
Location: Germany, Next to Hamburg

PostPosted: Sun 04 Mar '12 22:08    Post subject: Reply with quote

Rocker wrote:
Ok, I done that, but, what is [L] ?


The L says if the rule applies that it is the last rule.

----------
Rocker wrote:

I commented out all that lines and /: keeps returning 403.


I think it is more an issue of your document root and the configuration within the <Directory> Block
Back to top


Reply to topic   Topic: Why Apache returns 403 ? View previous topic :: View next topic
Post new topic   Forum Index -> Apache