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

时间:2015-05-20 10:38:09

标签: php apache .htaccess mod-rewrite whm

我有这个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=$1
RewriteRule ^banners/rotator/([0-9]+)\.gif$ /interface/display_banner_rotator.php?do=image&id=$1
RewriteRule ^banners/rotator/click/([0-9]+)$ /interface/display_banner_rotator.php?do=click&id=$1
RewriteRule ^banners/affiliates/([0-9]+)\.gif$ /interface/display_affiliate.php?do=image&id=$1
RewriteRule ^banners/([0-9]+)/click$ /interface/bannerads_click.php?id=$1
RewriteRule ^banners/ppc/([0-9]+)/click$ /interface/ppc_click.php?id=$1
RewriteRule ^banners/offsite/([0-9A-Z]+)$ /interface/offsiteadzonehandler.php?id=$1
RewriteRule ^banners/offsite/([0-9A-Z]+)/click/([0-9A-Z]+)$ /interface/offsiteadzonehandler.php?do=click&id=$1&cid=$2

# 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=$1  [L]
</IfModule>

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

1 个答案:

答案 0 :(得分:0)

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

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

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

并查看响应标题。