0

nodejs/express がルートでどのように機能するかをエミュレートしようとしています。index.phpルートを処理するためにすべてのトラフィックを転送しています ( AltoRouterを使用)。

私のファイル構造は次のようなものです:

-/
--public/
  |- assets
  |- ...
--routes/
  |- route.php
  |- ...
--index.php

たとえば、次の URL を見てください (すべて 404 を返す/リダイレクトする必要があります)。

http://testsite.com/routes

http://testsite.com/routes/route.php

http://testsite.com/somefile.php

ただし、そのように直接アクセスできるのはアセットのみです(含めたくありません/public/

http://testsite.com/assets/image.png

http://testsite.com/assets/styles/style.css

これは私がこれまでに持っているものです:

# Make sure mod_rewrite is on
<IfModule mod_rewrite.c>
    RewriteEngine on

    # This should allow us to get our assets and keep them public
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)\.(gif|jpg|png|jpeg|css|js|swf)$ /public/$1.$2 [L,NC]

    # Forward other traffic to index.php
    RewriteRule ^.+$ index.php [L]
</IfModule>

私が遭遇した1つの問題は次のとおりですhttp://testsite.com/routesここに画像の説明を入力

私の主な質問は、公開されていないものはアクセス可能であってはならないということだと思います(.htaccesが正しいかどうかはわかりません)

4

1 に答える 1