您如何确认 .htaccess 是否正常工作?

How do you confirm if .htaccess if working fine?

我有这个 htaccess,我不确定这些模块 mod_php5.c 、 mod_suphp.c 和 mod_rewrite.c 是否正常工作。我如何检查他们是否在工作并做好他们的工作?

尝试检查 mod_php5.c 、 mod_suphp.c 和 mod_rewrite.c 是否已安装,但它们未显示在 phpinfo();

我正在使用 Linux 服务器,有 WHM/cPanel,CentOS。

# PHP Flags
<IfModule mod_php5.c>
php_value include_path ".:/home/sitetalk/public_html"
php_flag display_errors off
php_flag magic_quotes_gpc off
php_value default_charset "utf-8"
php_value error_log "/home/sitetalk/public_html/../application_error_log"
</IfModule>

# If using suPHP set a custom INI path
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/sitetalk/public_html
</IfModule>

# Rewrites
<IfModule mod_rewrite.c>
RewriteEngine On

# Block all non-hostname attempts
RewriteCond %{HTTP_HOST} !^(www\.)?sitetalk.com$
RewriteRule . - [F]

# friendly banner codes
RewriteRule ^banners/([0-9]+)\.gif$ /interface/display_banner.php?do=display&id=
RewriteRule ^banners/rotator/([0-9]+)\.gif$ /interface/display_banner_rotator.php?do=image&id=
RewriteRule ^banners/rotator/click/([0-9]+)$ /interface/display_banner_rotator.php?do=click&id=
RewriteRule ^banners/affiliates/([0-9]+)\.gif$ /interface/display_affiliate.php?do=image&id=
RewriteRule ^banners/([0-9]+)/click$ /interface/bannerads_click.php?id=
RewriteRule ^banners/ppc/([0-9]+)/click$ /interface/ppc_click.php?id=
RewriteRule ^banners/offsite/([0-9A-Z]+)$ /interface/offsiteadzonehandler.php?id=
RewriteRule ^banners/offsite/([0-9A-Z]+)/click/([0-9A-Z]+)$ /interface/offsiteadzonehandler.php?do=click&id=&cid=

# HTTPS to HTTP on viewads page
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/interface/viewads.php [OR]
RewriteCond %{REQUEST_URI} ^/interface/viewads_ptc.php
RewriteRule (.*) http://www.revsurfprofit.com%{REQUEST_URI} [R,L,QSA]

#RewriteCond %{HTTPS} !=on
#RewriteCond %{REQUEST_URI} !^/interface/viewads.php
#RewriteCond %{REQUEST_URI} !^/interface/viewads_ptc.php
#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L,QSA]

# Referral code
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)(|/)$ index.php?ref=  [L]
</IfModule>

# Deny files
<files php.ini>
order deny,allow
deny from all
</files>

Apache 模块未显示在 phpinfo() 中。 您可以使用 运行 httpd -M 命令查看已加载哪些模块。

您还可以在每个 .htaccess 部分中设置一个特殊的 http-header 来检查它是否有效。 示例:

<IfModule mod_suphp.c>
Header set X-SuPHP-Works 1
</IfModule>

并查看响应 headers。