Zend Framework Url Rewrite 服务器、虚拟主机 配置

Apache HTTP Server

                All examples that follow use mod_rewrite, an official                module that comes bundled with Apache. To use it,                mod_rewrite must either be included at compile time or enabled as a Dynamic Shared Object (DSO). Please consult the                » Apache documentation for your                version for more information.           

 

Rewriting inside a VirtualHost (httpd.conf/php.ini)

                    Here is a very basic virtual host definition. These rules direct all requests                    to index.php, except when a matching file is found under                    the document_root.               

  1. <VirtualHost my.domain.com:80>
  2.     ServerName   my.domain.com
  3.     DocumentRoot /path/to/server/root/my.domain.com/public
  4.     RewriteEngine off
  5.     <Location />
  6.         RewriteEngine On
  7.         RewriteCond %{REQUEST_FILENAME} -s [OR]
  8.         RewriteCond %{REQUEST_FILENAME} -l [OR]
  9.         RewriteCond %{REQUEST_FILENAME} -d
  10.         RewriteRule ^.*$ - [NC,L]
  11.         RewriteRule ^.*$ /index.php [NC,L]
  12.     </Location>
  13. </VirtualHost>

                    Note the slash ("/") prefixing index.php; the rules for                    .htaccess differ in this regard.               

Rewriting within a .htaccess file

                    Below is a sample .htaccess file that utilizes                    mod_rewrite. It is similar to the virtual host                    configuration, except that it specifies only the rewrite rules, and the leading                    slash is omitted from index.php.               

  1. RewriteEngine On
  2. RewriteCond %{REQUEST_FILENAME} -s [OR]
  3. RewriteCond %{REQUEST_FILENAME} -l [OR]
  4. RewriteCond %{REQUEST_FILENAME} -d
  5. RewriteRule ^.*$ - [NC,L]
  6. RewriteRule ^.*$ index.php [NC,L]

                    There are many ways to configure mod_rewrite; if you                    would like more information, see Jayson Minard's » Blueprint for PHP Applications:                    Bootstrapping.           

    

Microsoft Internet Information Server (IIS 配置) web.config

                As of version 7.0, IIS now ships with a standard rewrite engine.                You may use the following configuration to create the appropriate rewrite rules.           

  1. <?xml version="1.0" encoding="UTF-8"?>

  2. <configuration>

  3.     <system.webServer>

  4.         <rewrite>

  5.             <rules>

  6.                 <rule name="Imported Rule 1" stopProcessing="true">

  7.                     <match url="^.*$" />

  8.                     <conditions logicalGrouping="MatchAny">

  9.                         <add input="{REQUEST_FILENAME}"

  10.                              matchType="IsFile" pattern=""

  11.                              ignoreCase="false" />

  12.                         <add input="{REQUEST_FILENAME}"

  13.                              matchType="IsDirectory"

  14.                              pattern=""

  15.                              ignoreCase="false" />

  16.                     </conditions>

  17.                     <action type="None" />

  18.                 </rule>

  19.                 <rule name="Imported Rule 2" stopProcessing="true">

  20.                     <match url="^.*$" />

  21.                     <action type="Rewrite" url="index.php" />

  22.                 </rule>

  23.             </rules>

  24.         </rewrite>

  25.     </system.webServer>

  26. </configuration>

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值