Jump to content

Recommended Posts

I'm building my own MVC framework. Everything works except one error in console(GET http://my-domain.com/ 403 (Forbidden)). It's caused because it tried to find index.php in document root. Why it keeps searching index.php in document root when i wrote this in .htaccess(which is in doc root):

RewriteEngine On
RewriteBase /
 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ public/bootstrap.php [L]

When I add index.php to doc root the error is gone but it shows the doc root index.php... I tried to redirect from index.php to my bootstrap.php file in public directory and it worked - all showed up like it had to, no errors in console But the php redirect slows down page. So the question is - why the f*ck is browser still searching for index.php, when I said to rewrite all requests to public/bootstrap­.php??
Thanks

Link to comment
https://forums.phpfreaks.com/topic/303704-htaccess/
Share on other sites

why the f*ck is browser still searching for index.php, when I said to rewrite all requests to public/bootstrap­.php??

1. It's not the browser.

2. You said to rewrite non-existent requests. Since / corresponds to your document root, and that document root most certainly does exist, the rewrite won't happen.

 

It's standard to use an index.php. Why not use one with

<?php

require $_SERVER["DOCUMENT_ROOT"] . "/public/bootstrap.php";
Link to comment
https://forums.phpfreaks.com/topic/303704-htaccess/#findComment-1545431
Share on other sites

 

1. It's not the browser.

2. You said to rewrite non-existent requests. Since / corresponds to your document root, and that document root most certainly does exist, the rewrite won't happen.

 

It's standard to use an index.php. Why not use one with

<?php

require $_SERVER["DOCUMENT_ROOT"] . "/public/bootstrap.php";

 

Link to comment
https://forums.phpfreaks.com/topic/303704-htaccess/#findComment-1545443
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.