php - Apache RewriteRule 在 http 下工作,而不是在 https 下工作

标签 php apache ssl centos redhat

我有一个 Apache RewriteRule,它在 httpd.conf 中的 http 下工作,但在 ssl.conf 中不在 https 下工作

我在 https 下导航到该文件时收到 500:内部服务器错误,但我在使用 http 时看到重定向。

DocumentRoot 是/var/www/html

我正在尝试将任何对/var/www/html/site/testfile.js 的请求重定向到/var/www/html/site/test.php。这在 http 下完全有效,如下所示:

<VirtualHost *:80> RewriteEngine on RewriteRule ^/site/testfile.js(\?.*)?$ /site/test.php$1 [P] </VirtualHost>

在 ssl.conf 下是这样设置的:

`<VirtualHost _default_:443>
RewriteEngine on
RewriteRule ^/site/testfile.js(\?.*)?$ /site/test.php$1 [P]
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel debug
SSLEngine on
SSLProtocol all -SSLv2  
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/star_domainname_ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/server.key
SSLCertificateChainFile /etc/pki/tls/certs/DigiCertCA.crt
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>
SetEnvIf User-Agent ".*MSIE.*" \
     nokeepalive ssl-unclean-shutdown \
     downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
      "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>`

任何帮助将不胜感激。

由于某些原因,日志记录 access.log 和 ssl_access 日志也没有写入。错误日志中没有任何内容可以解释为什么这不起作用。

最佳答案

通过在 SSl.conf 下将重写规则更改为以下内容解决了这个问题

重写规则 ^/site/testfile.js(\?.*)?$/site/test.php$1 [L]

关于php - Apache RewriteRule 在 http 下工作,而不是在 https 下工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24698771/

相关文章:

Asp.net Json Post 请求

ssl - 我的网站可以通过 ftp ://ftp. example.com 访问,它安全吗?

php - 计算 Average 和 LEFT JOIN 表

php - 在单个查询中获取具有 2 个外部表的表的 2 个不同行?

css - 使用 htaccess 编辑 apache 中目录 View 的默认标题

java - org.apache.http.client.methods.HttpPost 和 org.apache.commons.httpclient.methods.PostMethod 之间的区别?

ssl - Google Cloud Platform 上的 Bitnami 启用 SSL 问题 : Please fix DNS entries while enabling SSL

PHP mysql - 通过帖子获取相应的用户

php - 检查mysql表中的列中是否存在值

php - 使用 PHP 屏蔽图像生成 CGI 脚本的 URL