有一个奇怪的问题,我们只是试图将www重定向到非www,在.htacess中有无数种方法可以这样做,所有工作除了某些原因重写也从URL中删除/ cgi-bin /否则我们需要网站休息。示例网址:
http://www.example.com/cgi-bin/band.cgi?BandNum$5
重定向到
http://exmaple.com/band.cgi?BandNum$5
使用以下htaccess规则:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
我正在考虑Apache中的某些内容会影响cgi-bin,这会导致.htaccess规则出现问题,但我无法追踪它,想法?
谢谢!
这是完整的htaccess
Options -Indexes
#RewriteEngine On
#RewriteBase /
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
#RewriteCond %{REQUEST_URI} !^/cgi-bin/ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule ^item-(.*)_(.*)_(.*)_(.*).html$ auction.php?title=$1&item=$2&country=$3&ccid=$4
RewriteRule ^item-(.*)_(.*)_(.*).html$ auction.php?title=$1&item=$2&country=$3
RewriteRule ^item-(.*)_(.*).html$ auction.php?title=$1&item=$2
redirect 301 /mrfest2007/index.html https://example.com/cgi-bin/gletter.cgi
Apache conf:
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
</IfModule>
并且在域的实际虚拟主机中有:
ScriptAlias /cgi-bin/ /home/username/public_html/cgi-bin/