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

迅睿框架 更新 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
    @易学习:再次感谢

迅睿系统漏洞

站群分站系统
站群分站系统(2026-10-15)
子站域名新增llms.txt访问
GEO系统
GEO系统(2026-10-14)
修复下载zip空白地址问题 修复流量复刻和任务队列错误
GeoSeo收录宝
GeoSeo收录宝(2026-10-14)
新增 站长工具箱 前端首页自动调用meta 数据
滑块验证码 Gocaptcha
滑块验证码 Gocaptcha(2026-10-13)
基于开源项目 go-captcha 的行为验证码插件,滑动拼图、区域...
GeoSeo工具箱
GeoSeo工具箱(2026-10-13)
优化巡检任务
GeoSeo排名助手
GeoSeo排名助手(2026-10-11)
加入大模型自定义
SEO聚合关键字
SEO聚合关键字(2026-10-11)
优化关键字列表页最多支持1万篇文章,过多会导致服务器扛不住;
CMS内容同步复制
CMS内容同步复制(2026-10-10)
增加时间是否更新的开关