搜索
首页后端开发php教程destoon中URL Rewrite(伪静态)设置方法教程

  1. LoadModule rewrite_module libexec/mod_rewrite.so
  2. AddModule mod_rewrite.c
复制代码

Apache 2.x 的用户请检查 conf/httpd.conf 中是否存在如下一段代码:

  1. LoadModule rewrite_module modules/mod_rewrite.so
复制代码

如果存在,且以#开头,请删除#。然后在配置文件(通常就是 conf/httpd.conf或者conf/extra/httpd-vhosts.conf)中加入如下代码。

注意,如果网站使用通过虚拟主机来定义,请务必加到虚拟主机配置,即中去,如果加在虚拟主机配置外部将可能无法使用。 改好后,将 Apache 重启。 Apache conf文件配置(参考http://download.destoon.com/rewrite/apache.txt)规则:

  1. # Destoon B2B Rewrite Rules
  2. ErrorDocument 404 /404.php
  3. RewriteEngine On
  4. RewriteBase /
  5. RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php
  6. RewriteRule ^(.*)/file/(.*)\.php(.*)$ /404.php
  7. RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
  8. RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show.php?itemid=$2&page=$4
  9. RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list.php?catid=$2&page=$4
  10. RewriteRule ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show.php?itemid=$2&page=$3
  11. RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list.php?catid=$2&page=$3
  12. RewriteRule ^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$ $1/list.php?catid=$3&page=$4
  13. RewriteRule ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index.php?rewrite=$3
  14. RewriteRule ^(.*)/com/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$ $1/index.php?homepage=$2&file=$3&rewrite=$4
  15. RewriteRule ^(.*)/com/([a-z0-9_\-]+)/([a-z]+)([/])?$ $1/index.php?homepage=$2&file=$3
  16. RewriteRule ^(.*)/com/([a-z0-9_\-]+)([/])?$ $1/index.php?homepage=$2
复制代码

3、Nginx规则(参考http://download.destoon.com/rewrite/nginx.txt):

  1. rewrite ^/(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404.php last;
  2. rewrite ^/(.*)/file/(.*)\.php(.*)$ /404.php last;
  3. rewrite ^/(.*)-htm-(.*)$ /$1.php?$2 last;
  4. rewrite ^/(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ /$1/show.php?itemid=$2&page=$4 last;
  5. rewrite ^/(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ /$1/list.php?catid=$2&page=$4 last;
  6. rewrite ^/(.*)/show/([0-9]+)/([0-9]+)?([/])?$ /$1/show.php?itemid=$2&page=$3 last;
  7. rewrite ^/(.*)/list/([0-9]+)/([0-9]+)?([/])?$ /$1/list.php?catid=$2&page=$3 last;
  8. rewrite ^/(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$ /$1/list.php?catid=$3&page=$4 last;
  9. rewrite ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index.php?rewrite=$3 last;
  10. rewrite ^/(com)/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$ /index.php?homepage=$2&file=$3&rewrite=$4 last;
  11. rewrite ^/(com)/([a-z0-9_\-]+)/([a-z]+)([/])?$ /index.php?homepage=$2&file=$3 last;
  12. rewrite ^/(com)/([a-z0-9_\-]+)([/])?$ /index.php?homepage=$2 last;
复制代码

4、Zeus规则(参考http://download.destoon.com/rewrite/zeus.txt):

  1. match URL into $ with ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$
  2. if matched then
  3. set URL = /404.php
  4. endif
  5. match URL into $ with ^(.*)/file/(.*)\.php(.*)$
  6. if matched then
  7. set URL = /404.php
  8. endif
  9. match URL into $ with ^(.*)-htm-(.*)$
  10. if matched then
  11. set URL = $1.php?$2
  12. endif
  13. match URL into $ with ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$
  14. if matched then
  15. set URL = $1/show.php?itemid=$2&page=$4
  16. endif
  17. match URL into $ with ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$
  18. if matched then
  19. set URL = $1/list.php?catid=$2&page=$4
  20. endif
  21. match URL into $ with ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$
  22. if matched then
  23. set URL = $1/show.php?itemid=$2&page=$3
  24. endif
  25. match URL into $ with ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$
  26. if matched then
  27. set URL = $1/list.php?catid=$2&page=$3
  28. endif
  29. match URL into $ with ^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$
  30. if matched then
  31. set URL = $1/list.php?catid=$3&page=$4
  32. endif
  33. match URL into $ with ^(.*)/([a-z]+)/(.*)\.shtml$
  34. if matched then
  35. set URL = $1/$2/index.php?rewrite=$3
  36. endif
  37. match URL into $ with ^(.*)/com/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$
  38. if matched then
  39. set URL = $1/index.php?homepage=$2&file=$3&rewrite=$4
  40. endif
  41. match URL into $ with ^(.*)/com/([a-z0-9_\-]+)/([a-z]+)([/])?$
  42. if matched then
  43. set URL = $1/index.php?homepage=$2&file=$3
  44. endif
  45. match URL into $ with ^(.*)/com/([a-z0-9_\-]+)([/])?$
  46. if matched then
  47. set URL = $1/index.php?homepage=$2
  48. endif
复制代码

5、IIS6服务器 请下载 http://download.destoon.com/rewrite/IIS_Rewrite.zip 规则已经设置好,按readme.txt文件内容进行操作 如果网站支持httpd.ini文件,请使用如下规则(参考http://download.destoon.com/rewrite/httpd.ini):

  1. [ISAPI_Rewrite]

  2. # Destoon B2B www.destoon.com
  3. # 3600 = 1 hour
  4. CacheClockRate 3600
  5. RepeatLimit 32

  6. # Protect httpd.ini and httpd.parse.errors files

  7. # from accessing through HTTP
  8. RewriteRule ^(.*)\.(asp|aspx|asa|asax|dll|jsp|cgi|fcgi|pl)(.*)$ /404\.php
  9. RewriteRule ^(.*)/file/(.*)\.php(.*)$ /404\.php
  10. RewriteRule ^(.*)-htm-(.*)$ $1\.php\?$2
  11. RewriteRule ^(.*)/show-([0-9]+)([\-])?([0-9]+)?\.html$ $1/show\.php\?itemid=$2&page=$4
  12. RewriteRule ^(.*)/list-([0-9]+)([\-])?([0-9]+)?\.html$ $1/list\.php\?catid=$2&page=$4
  13. RewriteRule ^(.*)/show/([0-9]+)/([0-9]+)?([/])?$ $1/show\.php\?itemid=$2&page=$3
  14. RewriteRule ^(.*)/list/([0-9]+)/([0-9]+)?([/])?$ $1/list\.php\?catid=$2&page=$3
  15. RewriteRule ^(.*)/([A-za-z0-9_\-]+)-c([0-9]+)-([0-9]+)\.html$ $1/list\.php\?catid=$3&page=$4
  16. RewriteRule ^(.*)/com/([a-z0-9_\-]+)/([a-z]+)/(.*)\.html$ $1/index\.php\?homepage=$2&file=$3&rewrite=$4
  17. RewriteRule ^(.*)/com/([a-z0-9_\-]+)/([a-z]+)([/])?$ $1/index\.php\?homepage=$2&file=$3
  18. RewriteRule ^(.*)/com/([a-z0-9_\-]+)([/])?$ $1/index\.php\?homepage=$2
  19. RewriteRule ^(.*)/([a-z]+)/(.*)\.shtml$ $1/$2/index\.php\?rewrite=$3
复制代码

6、IIS7服务器 规则(参考http://download.destoon.com/rewrite/web.config.txt)为:

复制代码

Rewrite生效后,请在网站后台=》网站设置=》SEO优化=》URL Rewrite,选择“开启”提交。 然后进入各模块的模块设置“SEO设置”选择对应伪静态地址规则,选择“更新地址”提交即可。

以上通过实例介绍了destoon URL Rewrite(伪静态)的设置方法,希望对大家有所帮助。

推荐阅读:destoon入门教程与技巧实例


声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
哪些常见问题会导致PHP会话失败?哪些常见问题会导致PHP会话失败?Apr 25, 2025 am 12:16 AM

PHPSession失效的原因包括配置错误、Cookie问题和Session过期。1.配置错误:检查并设置正确的session.save_path。2.Cookie问题:确保Cookie设置正确。3.Session过期:调整session.gc_maxlifetime值以延长会话时间。

您如何在PHP中调试与会话相关的问题?您如何在PHP中调试与会话相关的问题?Apr 25, 2025 am 12:12 AM

在PHP中调试会话问题的方法包括:1.检查会话是否正确启动;2.验证会话ID的传递;3.检查会话数据的存储和读取;4.查看服务器配置。通过输出会话ID和数据、查看会话文件内容等方法,可以有效诊断和解决会话相关的问题。

如果session_start()被多次调用会发生什么?如果session_start()被多次调用会发生什么?Apr 25, 2025 am 12:06 AM

多次调用session_start()会导致警告信息和可能的数据覆盖。1)PHP会发出警告,提示session已启动。2)可能导致session数据意外覆盖。3)使用session_status()检查session状态,避免重复调用。

您如何在PHP中配置会话寿命?您如何在PHP中配置会话寿命?Apr 25, 2025 am 12:05 AM

在PHP中配置会话生命周期可以通过设置session.gc_maxlifetime和session.cookie_lifetime来实现。1)session.gc_maxlifetime控制服务器端会话数据的存活时间,2)session.cookie_lifetime控制客户端cookie的生命周期,设置为0时cookie在浏览器关闭时过期。

使用数据库存储会话的优点是什么?使用数据库存储会话的优点是什么?Apr 24, 2025 am 12:16 AM

使用数据库存储会话的主要优势包括持久性、可扩展性和安全性。1.持久性:即使服务器重启,会话数据也能保持不变。2.可扩展性:适用于分布式系统,确保会话数据在多服务器间同步。3.安全性:数据库提供加密存储,保护敏感信息。

您如何在PHP中实现自定义会话处理?您如何在PHP中实现自定义会话处理?Apr 24, 2025 am 12:16 AM

在PHP中实现自定义会话处理可以通过实现SessionHandlerInterface接口来完成。具体步骤包括:1)创建实现SessionHandlerInterface的类,如CustomSessionHandler;2)重写接口中的方法(如open,close,read,write,destroy,gc)来定义会话数据的生命周期和存储方式;3)在PHP脚本中注册自定义会话处理器并启动会话。这样可以将数据存储在MySQL、Redis等介质中,提升性能、安全性和可扩展性。

什么是会话ID?什么是会话ID?Apr 24, 2025 am 12:13 AM

SessionID是网络应用程序中用来跟踪用户会话状态的机制。1.它是一个随机生成的字符串,用于在用户与服务器之间的多次交互中保持用户的身份信息。2.服务器生成并通过cookie或URL参数发送给客户端,帮助在用户的多次请求中识别和关联这些请求。3.生成通常使用随机算法保证唯一性和不可预测性。4.在实际开发中,可以使用内存数据库如Redis来存储session数据,提升性能和安全性。

您如何在无状态环境(例如API)中处理会议?您如何在无状态环境(例如API)中处理会议?Apr 24, 2025 am 12:12 AM

在无状态环境如API中管理会话可以通过使用JWT或cookies来实现。1.JWT适合无状态和可扩展性,但大数据时体积大。2.Cookies更传统且易实现,但需谨慎配置以确保安全性。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

SublimeText3 英文版

SublimeText3 英文版

推荐:为Win版本,支持代码提示!

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器