Python SimpleHTTPServer [英] Python SimpleHTTPServer

查看:121
本文介绍了Python SimpleHTTPServer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让Python SimpleHTTPServer支持mod_rewrite?



我正在尝试使用Ember.js,利用History API作为位置API,并使它的工作,我必须:

  1)添加一些vhosts配置在WAMP(不简单),或
2 )运行python -m simpleHTTPServer(很简单)

所以当我在浏览器中打开它, localhost:3000 并点击导航(关于用户和例如),它运行良好。这些URL由Ember.js更改为 localhost:3000 / about localhost:3000 / users p>

但是当我尝试直接在新选项卡中打开 localhost:3000 / about 时,python web服务器只返回404。



我的.htaccess将所有内容重定向到index.html,但我怀疑python简单的Web服务器并没有真正读取htaccess文件(我在这里吗?



我已经尝试下载PHP 5.4.12并运行内置的Web服务器,url和htaccess mod_rewrite工作正常。但是我仍然不愿意从稳定的5.3升级到(可能仍然不够稳定)5.4.12,所以如果有一种方法来支持python简单的Web服务器中的mod_rewrite,那将是最好的。



感谢您的回答。

解决方案

SimpleHTTPServer 不支持apache模块,不遵守.htaccess,因为它不是apache。它不会与PHP工作。


Is there a way to make Python SimpleHTTPServer supports mod_rewrite?

I'm trying things with Ember.js with leveraging History API as the location API, and to make it work, I have to :

1) add some vhosts config in WAMP (not simple), or
2) run python -m simpleHTTPServer (very simple)

So when I opened it in the browser, localhost:3000 and clicked around the navigation (about and users for example), it worked well. The URLs are changed by Ember.js to localhost:3000/about and localhost:3000/users respectively.

But when I tried to open localhost:3000/about directly in new tab, the python web server simply returns 404.

I had my .htaccess redirecting everything to index.html, but I suspect python simple web server doesn't really read the htaccess file (am I right on this?)

I've tried downloading PHP 5.4.12 and run the built in web server, the url and htaccess mod_rewrite works well. But I'm still reluctant to upgrade from stable 5.3 to (probably still unstable enough) 5.4.12, so if there's a way to support mod_rewrite in python simple web server, that would be preferrable.

Thanks for the answer.

解决方案

SimpleHTTPServer does not support apache modules and does not respect .htaccess, because it isn't apache. it won't work with php either.

这篇关于Python SimpleHTTPServer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆