1

私は現在 SocialEngine をインストールしており、すべての URL は .htaccess ファイルによって処理され、socialengine.phpファイルにリダイレクトされ、適切な URL などが処理されます。

example.com/別のインデックス ページを配置したいので、スクリプトへのリダイレクトを停止したいと考えています。だから私は .htaccess ファイルがsocialengine.phpスクリプトを介して見つけることができない他のすべてのファイルを処理し、ルートファイルをindex.phpに保持したいと考えています。

その場合はindex.php.com/に送られ、それ以外の場合はsocialengine.phpを通じて処理されます。

以下は、変更が必要な .htaccess ファイルです。

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /socialengine\.php
  RewriteRule (.*) socialengine.php?rewrite=2 [L,QSA]
  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$

  RewriteRule (.*) socialengine.php?rewrite=1 [L,QSA]
  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ socialengine.php?rewrite=1 [L,QSA]
</IfModule>

返信ありがとうございます。

4

1 に答える 1

2

の直後に以下のコードを挿入しますRewriteEngine On

RewriteCond %{REQUEST_URI} ^/$
RewriteRule .* - [L]

説明: 最初の行は、 http ://example.com/への要求に一致します (この場合、REQUEST_URI が含ま/れます)。2 行目は、リクエストをそのまま渡します ( に注意してください-) 。

参考文献:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

于 2010-12-04T09:32:07.170 に答える