. Htaccess hides index. php and uses the pathinfo resource file path. no error is returned.

Source: Internet
Author: User
When the resource file local.comadminindex.css is used as the PATH_INFO request, the error 404 should be reported if the CSS file does not exist. But now 200 is returned...

My. htaccess file configuration

RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1

Access local.com/admin/index#correct

When accessing the resource file local.com/admin/index.css, the resource file is treated as a PATH_INFO request. if the CSS file does not exist, the error 404 should be reported. But now 200 is returned.

Please give me some advice on how to configure the. htaccess file.

Question added:

The following error occurs when you use the configuration provided by @ xialeistudio:

  1. Accessframe.com/index.cssNo error is reported in index.css. OK

  1. Accessframe.com/pathtest/index.cssNo index.css exists, but no error is reported.

  1. Problem Description: an error can be reported when you access a resource file that does not exist in the root path, but no error is reported when you access a non-existent resource file that does not exist in the root path.

Reply content:

My. htaccess file configuration

RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1

Access local.com/admin/index#correct

When accessing the resource file local.com/admin/index.css, the resource file is treated as a PATH_INFO request. if the CSS file does not exist, the error 404 should be reported. But now 200 is returned.

Please give me some advice on how to configure the. htaccess file.

Question added:

The following error occurs when you use the configuration provided by @ xialeistudio:

  1. Accessframe.com/index.cssNo error is reported in index.css. OK

  1. Accessframe.com/pathtest/index.cssNo index.css exists, but no error is reported.

  1. Problem Description: an error can be reported when you access a resource file that does not exist in the root path, but no error is reported when you access a non-existent resource file that does not exist in the root path.

RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_URI} !\.(css|js|png|jpeg|gif)$RewriteRule ^(.*)$ index.php/$1 [L]

For a configuration example, refer:

RewriteEngine on
RewriteBase/
RewriteRule (. *. css $ |. *. js $ |. *. jpg $ |. *. gif $ |. *. png $ |. *. ico $ |. *. swf $ |. *. txt $) $1 [L]
RewriteRule (. *) index. php [L]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.