php url
这功能要怎么实现
localhost/china 访问到 localhost/showservices.php?id=26
現時頁面的路徑是顯示它的頁面id;客人希望能夠在後台加上新功能,可自訂路徑的名字,當更改了路徑後,前台不會看到 ‘’id=xx’’,輸入新路徑時會自動連結到對應的頁面例子localhost/showservices.php?id=26改成localhost/china但仍然是連接到 showservices.php?id=26 的位置
回复讨论(解决方案)
localhost/china 访问到 localhost/showservices.php这个可以实现的
但是如果要用到id参数的话就要另外处理了 要不走post 要不通过其他方式传值过去 你仔细看你的这个帖子的url
http://bbs.csdn.net/topics/391966541 实际上391966541就是你的帖子的id 只不过他重新过了而已
如果要使用url重写 也就是伪静态
apache服务器需开启对应的rewrite模块 nginx也有相应的地方
如果是apache 一般重写的规则建议用.htaccess文件写在你的项目入口文件处 以下是一个apache .htaccess文件实例
<IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteRule ^/?$ /index.php/Api/PcOrder [L] RewriteCond $1 !^/?index.php RewriteCond $1 !^/?Public/ RewriteCond $1 !^/?robots.txt$</IfModule>
其中 RewriteEngine On下面即为重写部分 需要用到正则表达式 详细的还的楼主自己去了解 希望能帮到你
localhost/china 访问到 localhost/showservices.php?id=26
问题是china 这个不是固定的 一个id对应一个url
localhost/jan 要访问到 localhost/showservices.php?id=6
localhost 下面还有 php文件 没法区分
localhost/XXX
XXX 没有 .php 访问到 localhost/showservices.php
这个.htaccess文件要怎么写?
创建并命名为.htaccess文件
文件内容如下
RewriteEngine on
RewriteRule ^/china$ /showservices.php?id=26 [L]
你需要确保服务器有开启rewrite与支持.htaccess
参考:
http://blog.csdn.net/fdipzone/article/details/8762507
http://blog.csdn.net/fdipzone/article/details/8743940
localhost/china 访问到 localhost/showservices.php?id=26
问题是china 这个不是固定的 一个id对应一个url
localhost/jan 要访问到 localhost/showservices.php?id=6
localhost/XXX
XXX 没有 .php 访问到 localhost/showservices.php
这个.htaccess文件要怎么写?
三个字母组合,不少于 2600 种
四个字母组合,不少于14950 种
.....
你是打算把 apache 累死,还是打算让自己打字打疯?
你这种还不如直接跳到一个固定地址,然后根据路径再跳转。
用rewrite不适合匹配全部不适合
暴力点,直接301过去不行吗?
我发邮件问技术负责人,他就回复
Yes, you can do with htaccess feature, details as below:
1. Create the table to store the mapping records
2. Create the record based section to manage the mapping records
3. One create / update the record, will regenerate the htaccess file
翻译后我没明白什么意思
他的意思使用.htaccess用rewrite
不过我不建议。因为你匹配的太多了
应该先跳入一个公用页面,再跳转。
Yes, you can do with htaccess feature, details as below:
1. Create the table to store the mapping records
创建表来存储映射记录
这就一般短网址的处理方式一样了
2. Create the record based section to manage the mapping records
通过前缀来管理,实质上与 1 是一致的
3. One create / update the record, will regenerate the htaccess file
你也可以从映射表创建 .htaccess 文件
url 重写一般不宜超过 20 条规则,尤其是写在 .htaccess 中的
每次访问都要从硬盘加载并解析,并不管是否用到用不到
RewriteEngine on ErrorDocument 404(.*) showservices.php?url=$1
如何获取不存在页面参数?
localhost/test/CH1
CH1 是不存在的 获取该参数 showservices.php?url=CH1
上面是不行的
RewriteEngine On
RewriteCond %{QUERY_STRING} !^(.php)
RewriteRule ^(.*)$ showservices.php?url=$1 [QSA,PT,L]
后缀有 .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



The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Alipay PHP...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...
