douduo2407
2014-02-27 23:31 阅读 32
已采纳

删除文件扩展名谷歌应用程序引擎的PHP

Im looking to remove the .php on the end of my app's webpage but im not quite sure how to do so in my app.yaml

heres an example:

application: MY APP
version: 1
runtime: php
api_version: 1
threadsafe: yes

handlers:

- url: /
 script: index.php

- url: /index.php
 script: index.php 

But when I open up my app on my web browser, it says http:www.example.com/mypage.php

how can I get rid of the .php?

Thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongyuan6949 dongyuan6949 2014-02-28 00:44

    The app.yaml file will not result in the URL being re-written in the browser. You can write your app.yaml file to not require the php suffix on URLs

    handlers:
    
    - url: /
     script: index.php
    
    - url: /index
     script: index.php 
    
    - url: /foo
      script: bar.php
    

    Now the url /index will invoke the script index.php, /foo will invoke bar.php etc.

    If you want this sort of addressing for all of your php scripts then you could do something like

    - url: /(.+)
      script: (\1).php
    

    Now the URL /foo would call the script foo.php, /bar would call the script bar.php etc.

    点赞 评论 复制链接分享

相关推荐