質問

私は、CGI環境でbottle.pyを使用して正しく返すために、単純なインデックス以上のものを取得するのが困難でした。戻ってくると /こんにちは、404の応答が得られます。ただし、/index.py/helloをリクエストした場合

import bottle
from bottle import route

@route('/')
def index():
    return 'Index'

@route('/hello')
def hello():
    return 'Hello'

if __name__ == '__main__':
    from wsgiref.handlers import CGIHandler
    CGIHandler().run(bottle.default_app())

そして、これが私の.htaccessファイルです

DirectoryIndex index.py
<ifmodule mod_rewrite.c="">
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.py/$1  [L]
</ifmodule>

DHを使用しているため、ここからコードの多くをコピーしましたが、関連性があるように思えました。 http://blog.coderonfire.com/2010/02/running-bottle-python-micro-framework.html

助けてくれてありがとう。

役に立ちましたか?

解決

問題は、 <ifmodule> ブロックはApacheサーバーには関係ありません。Mod_rewriteへの指令は機能していません。以下から始めます .htaccess そして、必要な場合は、現在のApacheバージョンに従ってブロックを追加します。

DirectoryIndex index.py
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.py/$1  [L]
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top