以下是我的所有评论规则:
<Directory /home/*/public_html>
# prevent directory browsing
Options All -Indexes
# prevent access to htaccess files anywhere on the site
<Files .htaccess>
order allow,deny
deny from all
</Files>
# prevent DIRECT access to the /inc/ directory and its PHP files
<Files ~ "\.inc$">
order allow,deny
deny from all
</Files>
# custom error documents
ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 500 /error/500.html
# security requirement of the rewrite engine
Options +FollowSymLinks
# turn on rewrite engine
RewriteEngine On
# remove PHP extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
</Directory>
和
<Directory /home/*/public_html/images>
# caching
<IfModule mod_expires.c>
ExpiresActive On
<FilesMatch "\.(jpg|jpeg)$">
ExpiresDefault "modification plus 1 year"
Header set Cache-Control: "public, max-age=31536000"
Header unset Last-Modified
</FilesMatch>
</IfModule>
# turn on rewrite engine
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# if file cannot be found
RewriteRule ^.*$ /empty.jpg [NC,L]
</Directory>
我可以将这些规则添加到我的httpd.cnf的底部吗?还是有任何错误?还是我需要注意的其他事情?我不想搞砸任何东西,即使我只是在我的localhost上运行我的代码。
任何帮助将不胜感激。感谢。
答案 0 :(得分:1)
你可以将它们放在httpd.cnf
档中!他们会工作!你唯一应该注意的是把它们放在正确的位置(例如在正确的位置)