这功能要怎么实现
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还会跳转?

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

PHP is not dead. 1) The PHP community actively solves performance and security issues, and PHP7.x improves performance. 2) PHP is suitable for modern web development and is widely used in large websites. 3) PHP is easy to learn and the server performs well, but the type system is not as strict as static languages. 4) PHP is still important in the fields of content management and e-commerce, and the ecosystem continues to evolve. 5) Optimize performance through OPcache and APC, and use OOP and design patterns to improve code quality.

PHP and Python have their own advantages and disadvantages, and the choice depends on the project requirements. 1) PHP is suitable for web development, easy to learn, rich community resources, but the syntax is not modern enough, and performance and security need to be paid attention to. 2) Python is suitable for data science and machine learning, with concise syntax and easy to learn, but there are bottlenecks in execution speed and memory management.

PHP is used to build dynamic websites, and its core functions include: 1. Generate dynamic content and generate web pages in real time by connecting with the database; 2. Process user interaction and form submissions, verify inputs and respond to operations; 3. Manage sessions and user authentication to provide a personalized experience; 4. Optimize performance and follow best practices to improve website efficiency and security.

PHP uses MySQLi and PDO extensions to interact in database operations and server-side logic processing, and processes server-side logic through functions such as session management. 1) Use MySQLi or PDO to connect to the database and execute SQL queries. 2) Handle HTTP requests and user status through session management and other functions. 3) Use transactions to ensure the atomicity of database operations. 4) Prevent SQL injection, use exception handling and closing connections for debugging. 5) Optimize performance through indexing and cache, write highly readable code and perform error handling.

Using preprocessing statements and PDO in PHP can effectively prevent SQL injection attacks. 1) Use PDO to connect to the database and set the error mode. 2) Create preprocessing statements through the prepare method and pass data using placeholders and execute methods. 3) Process query results and ensure the security and performance of the code.


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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment