1

我的 cgi-bin 文件夹中有一些文件,我的 html 文件夹中有其他文件。

当我访问 /cgi-bin/index.cgi 时,会显示正常的索引页面。但是,当我只访问我的域时,例如“domain.com”,它会给我一个 apache 页面。可能是说那里没有 index.html 页面,我的 html 文件夹中也没有 index.html 页面。但是,我的 html 文件夹中的 .htaccess 文件应该可以正确重定向链接。但是,这些链接不会被重定向。

这是我拥有的 .htaccess 文件

deny from 127.1.1.4
deny from 127.1.1.1

AddDefaultCharset utf-8
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_CGI_AUTHORIZATION:%1]

RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule    ^([0-9A-Za-z]{12})(\/?.+|$)$        ?op=download1&id=$1&fname=$2 [L]
RewriteRule    ^([0-9A-Za-z]{12})(\/.+|\.html?|$)   ?op=download1&id=$1&fname=$2 [L]

RewriteRule    ^embed-([0-9A-Za-z]{12})\.html$      ?op=video_embed&file_code=$1 [L]
RewriteRule    ^embedmp3-([0-9A-Za-z]{12})\.html$   ?op=mp3_embed&file_code=$1 [L]
RewriteRule    ^box$                    /cgi-bin/index_box.cgi [L]

RewriteRule    ^$                   /cgi-bin/index.cgi [L]
RewriteRule    ^free([0-9]+)\.html$         /cgi-bin/index.cgi?op=registration&aff_id=$1 [L]
RewriteRule    ^checkfiles\.html$           /cgi-bin/index.cgi?op=checkfiles [L]
RewriteRule    ^contact\.html$              /cgi-bin/index.cgi?op=contact [L]
RewriteRule    ^premium\.html$              /cgi-bin/index.cgi?op=payments [L]
RewriteRule    ^login\.html$                ?op=login [L]
RewriteRule    ^catalogue(.*)\.html$            /cgi-bin/index.cgi?op=catalogue&date=$1 [L]
RewriteRule    ^news([0-9]*)\.html$         ?op=news&page=$1 [L]
RewriteRule    ^n([0-9]+)-.*\.html$         /cgi-bin/index.cgi?op=news_details&news_id=$1 [L]
RewriteRule    ^faq\.html$              /cgi-bin/index.cgi?op=page&tmpl=faq [L]
RewriteRule    ^tos\.html$              /cgi-bin/index.cgi?op=page&tmpl=tos [L]
RewriteRule    ^links\.html$                /cgi-bin/index.cgi?op=links [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule    ^pages/([a-z0-9\-\_]+).html      /cgi-bin/index.cgi?op=page&tmpl=$1$2 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule    ^users/([0-9A-Za-z\-_]{4,64})/?([0-9]+|$)    /cgi-bin/index.cgi?op=user_public&usr_login=$1&fld_id=$2 [L,NC]

RewriteRule    \.pm$                    /404.html [L]

ErrorDocument 404 /404.html

例如此链接:domain.com/?op=registration 不会重定向到正确的页面。

与此链接相同:domain.com/login.html

老实说,所有其他链接。我 99% 确定这是因为上面发布的 .htaccess 文件,但我似乎无法弄清楚索引重定向的问题。

4

1 回答 1

1

您的重写规则缺少 /,例如:

RewriteRule    ^/premium\.html$              /cgi-bin/index.cgi?op=payments [L]

更新:即使是主页重定向也需要 /。

首先废弃所有你拥有的东西,然后得到一个简单的版本:

deny from 127.1.1.4
deny from 127.1.1.1

AddDefaultCharset utf-8
RewriteEngine on
Options +FollowSymLinks
RewriteRule    ^$                    /cgi-bin/index.cgi [L]

假设可行,请一一添加条件和其他规则,直到您看到破坏它的原因。

于 2013-05-30T00:24:12.137 回答