thinkphp的伪静态有关问题
thinkphp的伪静态问题
高手些,请教一个问题:thinkphp中伪静态,设置后,怎么没有自己改变url地址,比如访问127.0.0.1/Index/index/id/12它没有变成127.0.0.1/Index/index/12.html 说师要开启url重写,我开启后还是没有效果(除了可以不加index.php),是不是要写伪静态规则? 这个伪静态规则咋个写?是不是在.htaccess文件中写?
------解决方案--------------------
这个应该是通过appach 或nginx来配吧,
------解决方案--------------------
一、如果你用pathinfo的话,127.0.0.1/Index/index/id/12应该是访问Index模块的index方法,传入参数id,值为12。
然后如果你使用了$this->display(); // 很久没用有点忘了。。。
它会调用Tpl/Index/index.html模板进行解析输出(你可以往模板里assign变量)
-------------------
二、而你所说的伪静态是在配置文件中设置了'URL_HTML_SUFFIX'=>'html'吗?
那127.0.0.1/Index/index/id/12 和 127.0.0.1/Index/index/12.html 的调用过程跟上面所说的是一样的。只不过后者更具有静态页面的URL特征。
--------------------
我不是很清楚你是否只是想实现第二点所说的那种伪静态,还是想访问“12.html”这个文件。
若是后者,把你“12.html”的文件重命名为index.html放到Tpl/Index/目录下即可。
------解决方案--------------------
可以通过设置URL_HTML_SUFFIX参数随意在URL的最后增加你想要的静态后缀,而不会影响当前操作的正常执行。
伪静态设置后,如果需要动态生成一致的URL,可以使用U方法在模板文件里面生成URL。
U('Blog/read?id=1')这个定义为例。
当前URL设置为REWRITE模式,并且设置了伪静态后缀为.html的话,同样的方法最后生成的URL地址是:
http://serverName/Blog/read/id/1.html
------解决方案--------------------
URL_HTML_SUFFIX'=>'html'

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
