1

Linux/UNIX で Web サイトを運営していますが、.htaccess ファイルとその中で使用されている構文についてまったく知りません。

システムにアクセスしhttp://pr.bananapages.netても、結果は得られません。しかし、ファイル名を追加すると、それが表示されます。元:http://pr.bananapages.net/index.html

注: URL は共有アクセス ホスティング サーバーのサブフォルダーを指していますが、実際には重要でwww.bananapages.net/pr/hamshackはありません。実際に指定せずに。

見つけたものはすべて試しましDirectoryIndexたが、ファイル名を使用しないと機能しません... (index.html)

これが私の現在の.htccessファイルです。

Options -MultiViews

DirectoryIndex system.php index.php

<IfModule mod_rewrite.c>
DirectoryIndex system.php index.php index.html

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)\.(.*)$
RewriteRule ^(.+[^/])$ http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]

# Google sitemap controller
RewriteRule ^sitemap.xml$ tmp/sitemap.xml [L]
RewriteRule ^tmp/sitemap.xml$ tmp/sitemap.xml [L]
RewriteRule ^index.html$ index.html [L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)(\.xml|\.php([0-9]*)|\.tpl|\.phtml|\.ini|\.inc|/)$ system.php?_p=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ system.php?_p=$1 [QSA,L]

</IfModule>

# compresses text, html, javascript, css and xml
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/javascript application/x-javascript
</IfModule>

注:ファイルの名前を変更する.htaccessと、ファイル名 (index.html) を指定しなくても機能します。.htaccessこのファイルには、これが望ましい方法で機能するのを妨げている何かがあると確信しています。

4

3 に答える 3

0

これを試すことができます:

あなたのすべてにおいて

RewriteCond %{REQUEST_FILENAME} !-f

ディレクトリでもファイルでもない場合にのみ書き換えを行うようにするには、次のように2倍にします。

編集

(Debian/Apache2 でテスト済み)。

Options -MultiViews

DirectoryIndex system.php index.php index.html

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)\.(.*)$
RewriteRule ^(.+[^/])$ http://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]

# Google sitemap controller
RewriteRule ^sitemap.xml$ tmp/sitemap.xml [L]
#RewriteRule ^tmp/sitemap.xml$ tmp/sitemap.xml [L]
#RewriteRule ^index.html$ index.html [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(\.xml|\.php([0-9]*)|\.tpl|\.phtml|\.ini|\.inc|/)$ system.php?_p=$1 [QSA,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ system.php?_p=$1 [QSA,L]

それがうまくいくかどうかを確認するには?いくつかのコメント付きの無限ループ リライタルールに注意してください。

于 2013-11-10T10:03:04.397 に答える
-1

これが答えです...

# Rules for subfolders
# for pr.bananapages.net
RewriteRule ^pr/(.*)$ pr/$1 [L]
# for jm.bananapages.net    
      RewriteRule ^jm/(.*)$ jm/$1 [L]
# and so on....
      RewriteRule ^dr/(.*)$ dr/$1 [L]
RewriteRule ^usvi/(.*)$ usvi/$1 [L]
RewriteRule ^bvi/(.*)$ bvi/$1 [L]
RewriteRule ^kitts/(.*)$ kitts/$1 [L]
RewriteRule ^ar/(.*)$ ar/$1 [L]
RewriteRule ^tt/(.*)$ tt/$1 [L]

なぜうまくいくのかはわかりませんが、うまくいくようです... Dale

于 2013-11-11T05:05:34.543 に答える