2013-05-29 32 views
1

我在我的cgi-bin文件夾和我的html文件夾中的其他文件中有一些文件。mod_rewrite沒有正確重定向Perl的CGI網址

當我訪問/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文件,但我似乎無法找出索引重定向的問題。

+0

爲幫助調試,你可以做的一件事是將所有這些重定向改爲'[L,R = 302]'。然後'捲曲'鏈接,看看你是否得到(通常由你的瀏覽器隱藏)重定向鏈接,包括。 '

該文件已移動here

' –

回答

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] 

假設作品,加入的條件和其他規則逐一直到你看到的就是打破它。

+0

仍然無法正常工作。 我通過在前面添加了幾個「/」更新了.htaccess文件,但沒有修復它。 http://pastebin.com/36Wv92Ju ^鏈接到新的.htaccess 你可以在這裏查看網站:http://50.7.6.116 索引頁:http://50.7.6.116/cgi-bin /index.cgi .htaccess也不會將主頁重定向到索引頁面。 – Maaz

+0

更新了我的回答 – ysth

+0

刪除了所有內容,並將其替換爲您更新答案的內容。但是,主頁仍然不會重定向到/cgi-bin/index.cgi/ – Maaz

相關問題