【发布时间】:2015-03-07 07:20:00
【问题描述】:
目标:将每个请求重定向到 index.php,除了 RewriteCond 中列出的文件和文件夹(及其内容)。
一位朋友确实和我一起设置了服务器,但还没有时间修复这个错误。页面自动以 HTTPS 结束。
当将此用作 000-default.conf (/etc/apache2/sites-enabled/000-default.conf) 时,页面不会重定向到 index.php。例如:访问 www.page.com/uploads/38 有效,尽管它应该重定向到 www.page.com/index.php。这很烦人,因为我正在模拟文件系统并且不想允许访问文件,至少不是那样。
a2ensite 000-default.conf:站点 000-default.conf 已启用 a2enmod 重写:模块重写已启用
这是我的 000-default.conf:
<VirtualHost *:80>
ServerAdmin root@page.com
DocumentRoot /var/www/default
ServerName www.page.com
ServerAlias page.com
RewriteEngine On
<Location />
RewriteBase /
Options -Indexes
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(index\.php|css|fonts|gfx|js|favicon\.ico)
RewriteRule ^(.*)$ index.php [L,QSA]
</Location>
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/default_error.log
CustomLog ${APACHE_LOG_DIR}/default_access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin root@page.com
DocumentRoot /var/www/default
ServerName www.page.com
ServerAlias page.com
RewriteEngine On
<Location />
RewriteBase /
Options -Indexes
Options +FollowSymlinks
RewriteCond %{REQUEST_URI} !^(index\.php|css|fonts|gfx|js|favicon\.ico)
RewriteRule ^(.*)$ index.php [L,QSA]
</Location>
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/default_error.log
CustomLog ${APACHE_LOG_DIR}/default_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/page.com.crt
SSLCertificateKeyFile /etc/ssl/page.com.key
SSLCertificateChainFile /etc/ssl/comodo-ca.crt
</VirtualHost>
在查看 default_error.log 时,我经常会发现这样的内容:
Request exceeded the limit of 10 internal redirects due to probable configuration error.
还有:
RSA server certificate CommonName (CN) `page.com' does NOT match server name!?
提前致谢。
【问题讨论】:
标签: apache .htaccess redirect vhosts