业务经理

微信扫描以上二维码

028-61286886

技术咨询

按自定义入口程序做的页面,怎么写伪静态规则

迅睿框架 更新 2020-09-08 12:17:26 心如意

http://localhost:81/go.php?id=760

上面地址是按自定义入口程序做的页面

请问怎么写伪静态规则,使这个页面的访问地址为:

http://localhost:81/go/760

方案

  • 官方研发实习技术 #1 · 2020-09-08 08:40:31
    可以,这个只能写在服务器的伪静态配置里面去了,说说你的服务器是什么,每一个服务器配置不一样
  • 心如意 #2 · 2020-09-08 08:42:24

    image
    官方研发实习技术
  • 官方研发实习技术 #3 · 2020-09-08 08:51:20
    RewriteRule ^/go/([0-9]+)$ /go.php?id=$1
  • 心如意 #4 · 2020-09-08 09:02:15
    谢谢,麻烦您看下下面错在哪里?在.htaccess 这样写RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]RewriteRule ^/go/([0-9]+)$ /go.php?id=$1在rewrite.php这样写 "go\/([0-9]+)" => "go.php?id=$1", //【独立模块测试规则】模块内容页 // 独立模块测试规则---解析规则----结访问http://localhost:81/go/760还是报错了
    image
  • 奋斗的犀牛 #5 · 2020-09-08 09:03:41
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/go/([0-9]+)$ /go.php?id=$1
    RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]
  • 新手上路 #6 · 2020-09-08 09:06:33
    没有放对地方
  • 心如意 #7 · 2020-09-08 09:30:14
    奋斗的犀牛 加在这个位置,全站报错了

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.More information about this error may be available in the server error log.Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
  • 黑苹果 #8 · 2020-09-08 09:33:56
    RewriteRule ^(.*)/go/([0-9]+)$ $1/go.php?id=$2
  • 成继 #9 · 2020-09-08 09:36:52

    Internal Server Error

    这个错误表示。htaccess里面的内容写错了
  • 心如意 #10 · 2020-09-08 09:43:21
    黑苹果 这个加上去还是报一样的错

    Internal Server Error

  • ibuc2t #11 · 2020-09-08 09:52:23
    RewriteRule ^go/([0-9]+)/$ /go.php?id=$1
  • 心如意 #12 · 2020-09-08 10:04:05
    ibuc2t RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^go/([0-9]+)/$ /go.php?id=$1RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]这样写,还是一样报错
  • 官方研发实习技术 #13 · 2020-09-08 10:05:20
    RewriteEngine On
    RewriteBase /
    RewriteRule ^go\/([0-9]+)\/$ /go.php?id=$1
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]
    试一试这种
  • 心如意 #14 · 2020-09-08 10:08:30
    官方研发实习技术 这样子不报错了,但是无效果
  • 官方研发实习技术 #15 · 2020-09-08 10:30:42
    htaccess文件不要改了,我也运行不出来改config/rewrite.php
     "go\/([0-9]+)"  => 'index.php?c=go&id=$1',
    新建
    image
    <?php namespace Phpcmf\Controllers;
    
    class Go extends \Phpcmf\Common
    {
        public function index() {
    		echo file_get_content(SITE_URL.'go.php?id='.intval($_GET['id']));exit;
        }
    }
  • 心如意 #16 · 2020-09-08 10:44:49
    官方研发实习技术 还是不行,我把GO相关的页面放出来共您参考页面一:/go.php
    <?php
    
    /**
     * 自定义程序
     */
    
    define('IS_API', basename(__FILE__, '.php')); // 项目标识
    define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); // 该文件的名称
    require((dirname(__FILE__)).'/index.php'); // 引入主文件
    页面二:\dayrui\My\Api\go.php
    <?php
    /**
     * 自定义程序的控制器代码
      这里写php代码,基于控制器类
     */
    
     $id = intval($_GET['id']);
     
     $data = \Phpcmf\Service::M()->table_site("sp")->get($id); // 这里吧demo改成你的模块目录名称
     
     $url = $data['sptklj'];
     
    // 输出url看看对不对,这里可以改进为301跳转等等,自由发挥
     ?>
    有了上面两个页面,可以正常访问:http://localhost:81/go.php?id=760然后试了上面大家热心的建议,还是不能实现伪静态http://localhost:81/go/760 访问rewrite.php 规则已经试过如下:
     "go\/([0-9]+)"  => 'index.php?c=go&id=$1',
      "go\/([0-9]+)"  => "go.php?id=$1",  //
    也都不行
  • 官方研发实习技术 #17 · 2020-09-08 10:48:11
    改config/rewrite.php
     "go\/([0-9]+)"  => 'index.php?c=go&id=$1',
    新建

    image

    <?php namespace Phpcmf\Controllers;
    
    class Go extends \Phpcmf\Common
    {
        public function index() {
    		
    		/**
     * 自定义程序的控制器代码
      这里写php代码,基于控制器类
     */
    
     $id = intval($_GET['id']);
     
     $data = \Phpcmf\Service::M()->table_site("sp")->get($id); // 这里吧demo改成你的模块目录名称
     
     $url = $data['sptklj'];
     
    // 输出url看看对不对,这里可以改进为301跳转等等,自由发挥
    		
        }
    }
  • 心如意 #18 · 2020-09-08 10:48:11
    补充上面http://localhost:81/go/760访问提示如下:
    image
  • 华山论剑 #19 · 2020-09-08 10:49:55
    新建控制器做伪静态就行了,官方的方案最佳
  • 心如意 #20 · 2020-09-08 10:54:23
    官方研发实习技术 已增加规则
    image
    已增加 文件\dayrui\Core\Controllers\go.php"仍然报错 应用程序(go)不存在
  • __流年__ #21 · 2020-09-08 10:57:12
    你这个是铭文规则需要写在最前面
  • 官方研发实习技术 #22 · 2020-09-08 10:58:22
    1、规则写前面,
    image
    2、 文件\dayrui\Core\Controllers\go.php 改成 Go.php,首字母大写
  • 成继 #23 · 2020-09-08 11:03:58
    老用户告诉你,二次开发一定不要改系统的文件
  • 心如意 #24 · 2020-09-08 11:05:18
    官方研发实习技术 现在不报错了,但是http://localhost:81/go/760网页是空白的,是不是因为RUL里面没有ID了,页面get不到id?
  • 心如意 #25 · 2020-09-08 11:05:52
    成继 没有改过系统问题,都是新增的自定义入口程序
  • 心愿未了 #26 · 2020-09-08 11:07:20

    image
    你这里没有写输出的文字,当然是一片白白色了
  • 心如意 #27 · 2020-09-08 11:34:57
    心愿未了
    <?php namespace Phpcmf\Controllers;
    
    class Go extends \Phpcmf\Common
    {
        public function index() {
    		
    		/**
     * 自定义程序的控制器代码
      这里写php代码,基于控制器类
     */
    
     $id = intval($_GET['id']);
     
     $data = \Phpcmf\Service::M()->table_site("sp")->get($id); // 这里吧demo改成你的模块目录名称
     
     $url = $data['sptklj']; // 输出url看看对不对,这里可以改进为301跳转等等,自由发挥
    
        }
    }
     ?>
     <html>  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head> 
    <body>
    <?php echo $id;?>
    <?php echo $url;?>
    </body>
    </html>
    这样输出也是空白
  • 易学习 #28 · 2020-09-08 11:41:16
    满意答案
    你不会php吗,怎么可以这样写html啊
    <?php namespace Phpcmf\Controllers;
    
    class Go extends \Phpcmf\Common
    {
        public function index() {
    		
    		/**
     * 自定义程序的控制器代码
      这里写php代码,基于控制器类
     */
    
     $id = intval($_GET['id']);
     
     $data = \Phpcmf\Service::M()->table_site("sp")->get($id); // 这里吧demo改成你的模块目录名称
     
     $url = $data['sptklj']; // 输出url看看对不对,这里可以改进为301跳转等等,自由发挥
     
     echo ' <html>  
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head> 
    <body>
    '.$id.'           - -----------            '.$url.'
    </body>
    </html>';
    
        }
    }
     ?>
  • 心如意 #29 · 2020-09-08 11:45:56
    易学习 真不会PHP,只会html,谢谢感谢各位大神的热心、耐心解答谢谢
  • 心如意 #30 · 2020-09-08 11:53:46
    易学习 请问要给这个页面能否指定模板名称为go.html,要怎样写呢?
  • 易学习 #31 · 2020-09-08 11:56:24
    \Phpcmf\Service::V()->display('go.html');
    http://help.xunruicms.com/206.html 手册有现成的,基础而已
  • 心如意 #32 · 2020-09-08 12:17:26
    @易学习:再次感谢

迅睿系统漏洞

GeoSeo收录宝
GeoSeo收录宝(2026-09-16)
ai发布增强: 1 新增Cron 心跳记录,任务列表实时显示。 ...
导入微信文章
导入微信文章(2026-09-15)
优化排版缺少文字情况
GEO系统
GEO系统(2026-09-15)
运营客户端,防止误触阴影处关闭对话框
独立站群系统
独立站群系统(2026-09-14)
子站独立部署时修复同步附件失败问题
在线客服
在线客服(2026-09-13)
修复删除会话报错问题 删除会话时联动删除聊天图片
在线考试竞赛系统
在线考试竞赛系统(2026-09-12)
增加投票功能 考试功能拓展 注意:更新后需要执行系统更新,更新数...
网上信箱
网上信箱(2026-09-12)
修复新版本兼容问题
GeoSeo工具箱
GeoSeo工具箱(2026-09-11)
修正历史记录推送
微信系统
微信系统(2026-09-11)
增加数据统计总览界面 账号管理增加服务和公众号的区别 菜单管理支持更...
答题系统
答题系统(2026-09-11)
一站式在线答题系统,支持真题考试、题库练习和错题本,适合培训、考证、...