


ThinkPHP32URL rewrites the entry file indexphp of the hidden application
可以通过URL重写隐藏应用的入口文件index.php,下面是相关服务器的配置参考:
[ Apache ]
- httpd.conf配置文件中加载了mod_rewrite.so模块
- AllowOverride None 将None改为 All
- 把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下
<ol> <li><code><span><IfModule</span><span>mod_rewrite</span><span>.</span><span>c</span><span>></span></code></li> <li><code><span> RewriteEngine on</span></code></li> <li><code><span> RewriteCond %{REQUEST_FILENAME} !-d</span></code></li> <li><code><span> RewriteCond %{REQUEST_FILENAME} !-f</span></code></li> <li><code><span> RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</span></code></li> <li><code><span></IfModule></span></code></li> </ol>
[ IIS ]
如果你的服务器环境支持ISAPI_Rewrite的话,可以配置httpd.ini文件,添加下面的内容:
<ol><li><code><span>RewriteRule</span><span>(.*)</span><span>$ </span><span>/</span><span>index\.php\?s</span><span>=</span><span>$1 </span><span>[</span><span>I</span><span>]</span></code></li></ol>
在IIS的高版本下面可以配置web.Config,在中间添加rewrite节点:
<ol> <li><code><span><rewrite></span></code></li> <li><code><span><rules></span></code></li> <li><code><span><rule</span><span>name</span><span>=</span><span>"OrgPage"</span><span>stopProcessing</span><span>=</span><span>"true"</span><span>></span></code></li> <li><code><span><match</span><span>url</span><span>=</span><span>"^(.*)$"</span><span>/></span></code></li> <li><code><span><conditions</span><span>logicalGrouping</span><span>=</span><span>"MatchAll"</span><span>></span></code></li> <li><code><span><add</span><span>input</span><span>=</span><span>"{HTTP_HOST}"</span><span>pattern</span><span>=</span><span>"^(.*)$"</span><span>/></span></code></li> <li><code><span><add</span><span>input</span><span>=</span><span>"{REQUEST_FILENAME}"</span><span>matchType</span><span>=</span><span>"IsFile"</span><span>negate</span><span>=</span><span>"true"</span><span>/></span></code></li> <li><code><span><add</span><span>input</span><span>=</span><span>"{REQUEST_FILENAME}"</span><span>matchType</span><span>=</span><span>"IsDirectory"</span><span>negate</span><span>=</span><span>"true"</span><span>/></span></code></li> <li><code><span></conditions></span></code></li> <li><code><span><action</span><span>type</span><span>=</span><span>"Rewrite"</span><span>url</span><span>=</span><span>"index.php/{R:1}"</span><span>/></span></code></li> <li><code><span></rule></span></code></li> <li><code><span></rules></span></code></li> <li><code><span></rewrite></span></code></li> </ol>
[ Nginx ]
在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:
<ol> <li><code><span> location </span><span>/</span><span>{</span><span>// …..省略部分代码</span></code></li> <li><code><span>if</span><span>(!-</span><span>e $request_filename</span><span>)</span><span>{</span></code></li> <li><code><span> rewrite </span><span>^(.*)</span><span>$ </span><span>/</span><span>index</span><span>.</span><span>php</span><span>?</span><span>s</span><span>=</span><span>$1 </span><span>last</span><span>;</span></code></li> <li><code><span>break</span><span>;</span></code></li> <li><code><span>}</span></code></li> <li><code><span>}</span></code></li> </ol>
其实内部是转发到了ThinkPHP提供的兼容模式的URL,利用这种方式,可以解决其他不支持PATHINFO的WEB服务器环境。
如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称。youdomain需要按照入口文件index.php的目录来确定。
<ol> <li><code><span>location </span><span>/</span><span>youdomain</span><span>/</span><span>{</span></code></li> <li><code><span>if</span><span>(!-</span><span>e $request_filename</span><span>){</span></code></li> <li><code><span> rewrite </span><span>^</span><span>/youdomain/</span><span>(.*)</span><span>$ </span><span>/</span><span>youdomain</span><span>/</span><span>index</span><span>.</span><span>php</span><span>?</span><span>s</span><span>=</span><span>$1 </span><span>last</span><span>;</span></code></li> <li><code><span>}</span></code></li> <li><code><span>}</span></code></li> </ol>
原来的访问URL:
http://serverName/index.php/模块/控制器/操作/[参数名/参数值...]
设置后,我们可以采用下面的方式访问:
http://serverName/模块/控制器/操作/[参数名/参数值...]
默认情况下,URL地址中的模块不能省略,如果你需要简化某个模块的URL访问地址,可以通过设置模块列表和默认模块或者采用子域名部署到模块的方式解决,请参考后面的模块和域名部署部分。
以上就介绍了ThinkPHP32URL重写隐藏应用的入口文件indexphp,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

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

index.html represents the home page file of the web page and is the default page of the website. When a user visits a website, the index.html page is usually loaded first. HTML (HypertextMarkupLanguage) is a markup language used to create web pages, and index.html is also an HTML file. It contains the structure and content of a web page, as well as tags and elements used for formatting and layout. Here is an example index.html code: <

The Chinese meaning of request is "request". It is a global variable in PHP and is an array containing "$_POST", "$_GET" and "$_COOKIE". The "$_REQUEST" variable can obtain data and COOKIE information submitted by POST or GET.

How to use the urllib.request.urlopen() function in Python3.x to send a GET request. In network programming, we often need to obtain data from a remote server by sending an HTTP request. In Python, we can use the urllib.request.urlopen() function in the urllib module to send an HTTP request and get the response returned by the server. This article will introduce how to use

The Request object in PHP is an object used to handle HTTP requests sent by the client to the server. Through the Request object, we can obtain the client's request information, such as request method, request header information, request parameters, etc., so as to process and respond to the request. In PHP, you can use global variables such as $_REQUEST, $_GET, $_POST, etc. to obtain requested information, but these variables are not objects, but arrays. In order to process request information more flexibly and conveniently, you can

The role and significance of Request in PHP In PHP programming, Request is a mechanism for sending requests to the Web server. It plays a vital role in Web development. Request is mainly used to obtain data sent by the client, such as form submission, GET or POST request, etc. Through Request, the data input by the user can be obtained, and the data can be processed and responded to. This article will introduce the role and significance of Request in PHP and give specific code examples.

URL jump The URL jump mentioned here is to jump to another URL when the user accesses one URL. A common application scenario is to let multiple domain names jump to the same URL (for example, let the old domain name jump to a new domain name), jump static file requests to CDN, etc. Jump to different sites according to the user's device (PC version) , wap version), etc. URL jump can be achieved by setting the window.location on the page with js or by setting the header with php. Of course, it can also be implemented using the rewrite function of nginx. The nginxrewrite module rewrite is the static rewrite module of nginx. The basic usage is rewritepattenre.

1. Create a new file called request.js and import Axios: importaxiosfrom'axios'; 2. Create a function called request and export it: This will create a function called request and export it Set up a new Axios instance with a base URL. To add timeout settings in a wrapped Axios instance, you can pass the timeout option when creating the Axios instance. exportconstrequest=axios.create({baseURL:'https://example.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code
