1

まったく同じ .htaccess ファイルを使用すると、ローカルの LAMP サーバー (mamp pro 経由) と運用サーバーの動作が異なります。別の構成が問題になっていると思いますが、どの構成ですか?

私のローカル サーバーでは、 http: //domain.com/section/item/ が正しく http://domain.com/index.php?section= $1&item=$2 にリダイレクトさます

私の本番サーバーでは、 http://domain.com/section/item/はhttp://domain.com/section/item/index.htmlへのアクセスを提供し ます

本番サーバーを開発サーバーのように動作させるにはどうすればよいですか?

役立つ場合に備えて、htaccessファイルの内容を次に示します。

<IfModule mod_rewrite.c>

RewriteEngine on
Options +FollowSymLinks

#--------------------------------------------
# PRETTY URLS
#--------------------------------------------


# if the following conditions are met, SKIP the rewriteRules.
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

# Externally redirect to add missing trailing slash
RewriteRule [^/]$ %{REQUEST_URI}/ [R,L]

# SIX PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3&content=$4&id=$5&title=$6 [NC,L,QSA]

# FIVE  PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3&content=$4&id=$5 [NC,L,QSA]

# FOUR PARAMS
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3&content=$4 [QSA,L]

# THREE PARAMS : projects/touch/texts/
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2&menu=$3 [QSA,L]

# TWO PARAMS: downloads
RewriteRule ^downloads/([^/]+)/$ index.php?section=downloads&item=$1 [QSA,L]

# TWO PARAMS:
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?section=$1&item=$2 [QSA,L]

# TAG URL : index.php?tag=url+encoded+keyword
RewriteRule ^tag/([\w-]+)/$ index.php?tag=$1 [NC,L,QSA]

# ONE PARAM
RewriteRule ^([\w-]+)/$ index.php?section=$1 [L,QSA]

#--------------------------------------------
# END PRETTY URLS
#--------------------------------------------

</IfModule>
4

2 に答える 2

0

2 つの変更を加えてみてください。

.htaccess ファイルの上に次の行を追加します。

DirectoryIndex index.php

次に、最初のルールを次のように変更します。

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

編集:これも試してください:

Options +FollowSymLinks -MultiViews
于 2013-09-27T17:04:48.937 に答える
0

はい、両方のファイルのディレクトリ構造はまったく同じです

すべての設定がどのように正確に行われたかはわかりませんが、ロードされるモジュールの順序が開発と本番 (ロングショット) で異なる可能性があり、URL 処理でモジュールが適用される順序に影響を与える可能性がありますパイプライン。mod_autoindex や mod_dir のような順序または何かが異なるため、mod_rewrite が何かを行う機会を得る前に/section/item/、 のリクエストが解決されます。つまり、次の条件が true になります。/section/item/index.html

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

また、他のルールは適用されないため、/section/item/index.htmlサービスが提供されます。

このようなものを修正する方法については、サーバー構成でディレクトリ インデックスをオフにするか (どこでもコメント アウトすることにより)、または提供されているディレクトリに存在しないものに設定することができると思います。

DirectoryIndex _index.php
于 2013-09-27T17:31:29.817 に答える