开发者

How can I put Pyramid in front of a PHP website using the same webserver?

The scenario is: I current have an old website that run开发者_StackOverflow社区s on PHP. Over time, that code has become hacked up and messy. It's due for a rewrite. However, I don't have time to do that rewrite yet. But I'd like to plan for it in the future.

What I need to do now is add a 'welcome' type page to the website. I'd like to code that in Python using the Pyramid framework.

The old sites URL structure is this:

http://website.com/XXXXXX

Where the X is the short URL id.

What I was thinking of doing was using Apaches LocationMatch config to catch the short URL. Something like:

<LocationMatch "/^([a-zA-Z0-9]{6})$">

This would then redirect the request to the PHP portion of the website. Everything else would be caught by Pyramid.

I'm not sure how to action this. Does Apache have an else type clause for LocationMatch? How would I tell it to serve the PHP files for /XXXXXX matches and send everything else to Pyramid?

Server Notes:

  • Apache2 + PHP (Debian package)
  • mod_wsgi 3.3
  • Python2.7


I am not sure about Apache configuration, but you could use wphp, a wsgi middleware for serving php.

http://pythonpaste.org/wphp/


Use recipes for using AddHandler described in:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#The_Apache_Alias_Directive

Apply the AddHandler and the rewrite rule to your DocumentRoot directory. Then add the SCRIPT_NAME fixup to your WSGI script file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜