`
liu86th
  • 浏览: 119119 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

[apache]apache配置url重写示例

 
阅读更多

[1] 首先修改http.conf文件

#LoadModule rewrite_module modules/mod_rewrite.so 
#去掉前面的分号

 

[2] 然后修改相应的AllowOverride None重写为AllowOverride All设置

<Directory "d:/wamp/www/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Order Deny,Allow
    Allow from All
    #Allow from 127.0.0.1

</Directory>

 

[3] 之后,在d:/wamp/www/目录下,新建.htassess文件,内容为

 

RewriteEngine On 
RewriteRule index.html index.php
RewriteRule ^demo\/list-(\d+)-(\d+).html$ /demo/list\.php\?id=$1&page=$2  

注释:
RewriteRule index.html index.php 匹配index.html -> index.php
RewriteRule ^demo\/list-(\d+)-(\d+).html$ /demo/list\.php\?id=$1&page=$2  匹配为http://localhost/demo/list-123-123.html映射为http://localhost/demo/list.php?id=12&page=234

 

 

分享到:
评论

相关推荐

    UrlReWrite(Url重写或伪静态)完美示例源码

    URL重写技术在今天已不是什么新鲜的话题了,在Apache服务器提供了名为mod_rewrite的URL重写模块,而在IIS服务器上,也有很多商业的ISAPI 筛选器模块可供使用。然而这对于我们,没有很多的资金或使用的共享服务器,...

    CI Nginx IIS Apache URL重写

    `.txt`文件可能是Nginx的配置示例,其中包含了URL重写的规则。Nginx使用`location`指令来处理URL,并结合`rewrite`指令实现重写。例如: ```nginx server { listen 80; server_name example.com; location / { ...

    Url 重写示例.rar

    以下是一个基于Apache服务器的URL重写示例,使用的是.htaccess文件: ```apacheconfig RewriteEngine On # 将所有以.php结尾的请求重写为.html RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^(.*)\.php$ ...

    URL重写的一个例子

    1. **服务器配置**:大多数Web服务器(如Apache、IIS)都支持URL重写模块,通过配置规则文件(如Apache的`.htaccess`或IIS的`web.config`)来实现URL转换。 2. **框架内置支持**:许多Web框架(如ASP.NET MVC、Ruby...

    URL重写URL重写URL重写

    这一过程通常涉及到HTTP服务器的配置文件,如Apache的`.htaccess`文件或IIS的web.config文件,以及服务器的URL重写模块,如Apache的mod_rewrite模块。 二、URL重写的优势 1. **用户友好**:美观、简洁的URL更容易...

    URL 重写类 url class

    `.htaccess` 文件是一个用于控制 Apache 服务器目录访问的配置文件,它可以用来实现 URL 重写规则。 `class.cleanurl.php` 可能定义了一个名为 `CleanUrl` 的类,该类包含方法用于解析和生成重写后的 URL。这个类...

    url重写 iis php web.config

    以下是一个基本的`.web.config`文件配置示例,用于实现URL重写: ```xml &lt;match url="^article/([0-9]+)/(.*)" /&gt; &lt;action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" ...

    自己写的url重写

    URL重写的核心原理是通过服务器端的规则引擎(如Apache的mod_rewrite模块或IIS的URL Rewrite Module)将用户访问的友好的、易于理解的URL转换为服务器能够识别的实际处理请求的复杂URL。这样做有以下几个主要好处: ...

    urlrewrite url地址重写

    - **Apache mod_rewrite**:Apache服务器的模块,通过配置.htaccess文件实现URL重写。 - **UrlRewriteFilter**:这是一个基于Java的开源过滤器,常用于Spring MVC等Java Web应用中,通过web.xml配置实现URL重写。 ...

    tomcat服务器以url重写的方式除去两个opencms

    在OpenCms中,这通常通过配置Apache Tomcat服务器或者使用内建的URL重写机制实现。Apache Tomcat是一个流行的Java应用服务器,用于运行基于Java Servlet和JavaServer Pages(JSP)的应用。 要实现"除去两个opencms...

    伪静态URL重写技术

    URL重写是通过服务器端的配置,如Apache的`.htaccess`文件或IIS的URL重写模块,来实现URL的转换。当客户端请求一个伪静态URL时,服务器会根据预先定义的规则将其解析为实际的动态URL,执行相应的程序并返回结果。...

    URL重写

    - Nginx服务器:在Nginx配置文件中使用rewrite指令进行URL重写。 - ASP.NET MVC:利用RouteConfig.cs文件定义路由规则。 - PHP框架:如Laravel、Symfony等,都有内置的URL重写机制。 4. 示例: - Apache `....

    Apache2.2 初级URL重写指南(RewriteRule)

    Apache作为一款广泛使用的Web服务器软件,提供了强大的URL重写功能,通过`.htaccess`文件或Apache配置文件中的`RewriteRule`指令实现灵活的URL映射与重定向。 #### 二、基础概念 1. **RewriteEngine**:开启或关闭...

    PHP网址重定向,URL重写教程

    在深入学习如何使用`.htaccess`文件进行URL重写之前,我们需要确保Apache服务器已正确安装并配置好相关模块。以下是必要的步骤: 1. **开启mod_rewrite.so模块** - 打开Apache配置文件`httpd.conf`。 - 查找`...

    Apache服务器下配置URL 态化的Rewrite规则.docx

    Apache服务器下的URL重写(Rewrite)规则是用于实现URL静态化的重要技术,这对于提升网站的搜索引擎优化(SEO)有着显著的效果。动态URL由于包含多种参数,往往比静态URL更难被搜索引擎理解和索引。通过Rewrite规则,...

    url重写示例

    在本示例中,我们将深入探讨URL重写的原理、应用场景和实现方法,以WebSite1为例进行讲解。 一、URL重写原理 URL重写,简单来说,就是将用户请求的不友好或者动态URL转换为友好、静态化的URL。不友好的URL通常包含...

Global site tag (gtag.js) - Google Analytics