Home Backend Development PHP Tutorial PHP框架queryphp教程:入门九 怎么去掉index.php

PHP框架queryphp教程:入门九 怎么去掉index.php

Jun 13, 2016 pm 12:57 PM
gt html index php

PHP框架queryphp教程:入门九 如何去掉index.php

去除index.php测试

C:\WINDOWS\system32\drivers\etc\hosts文件添加一行

内容如下

127.0.0.1 localhost
192.168.0.10 www.tjwzjs.cn

192.168.0.10的是你自己apache使用的IP,就是下面

*号中的IP,反证能访问你的本地网卡就可以了

http://www.tjwzjs.cn/queryphp/project/index.php/default/index

配置后希望可以变成这样子

http://www.tjwzjs.cn/queryphp/project/default/index.html

记得在inc.ini.php文件里面加多一行

$config['html']='.html'; 或把前面那个//去掉,这样就可以了

虚拟主机配置测试,AllowOverride FileInfo 将会使用.htaccess配置

虚拟主机配置测试文件在apache虚拟主机里面:

Order allow,deny
Allow from all
AllowOverride FileInfo?
?
DocumentRoot "D:/work"
ServerName "www.app.com"

.htaccess文件 放在project目录下面 就是每个项目目录下面,这样就会访问同级目录

index.php文件

index.php 目录下.htaccess文件:

RewriteEngine On
?
# uncomment the following line, if you are having trouble
# getting no_script_name to work
#RewriteBase /
?
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
?
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
?
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]

------------------------

程序中使用url_for()方式

模板中示示例 我们还是以CURD方式?

">编辑
">删除

下载后在并在apache设置www.app.com 在c:/windows/system

http://www.tjwzjs.cn/queryphp/project/curd/index

是不是可以显示内容了

如果显示了 在framework\config\inc.ini.php 文件中把下面这行内容去掉注释

//$config['html']='.html';//开启.html结尾url

http://www.tjwzjs.cn/queryphp/project/curd/index.html 访问

是不是可以看到内容了

所有链接都带.html结尾了。那我们有时候想不要.html结尾怎么办

">删除

url_for(url,true);方式 表示不要html结尾

删除会变成这样子

http://www.tjwzjs.cn/queryphp/project/curd/delete/id/2?

原文来源:http://tjwzjs.cn/news/knowledge/2012/1210/56.html
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

See all articles