PHP Advanced and Object-Oriented Programming Third Edition

 <?php
//D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess\mod_rewrite.php echo '?w='.$_GET['w'].'&wb='.$_GET['wb']; /*
http://localhost/0613pm/w_wwwroot/n/test_htaccess/mod_rewrite.php?w='cheer'&wb='time'
http://localhost/0613pm/w_wwwroot/n/test_htaccess/mod_rewrite.php?w=%27cheer%27&wb=%27time%27
?w='cheer'&wb='time'
*/ /*
http://localhost/0613pm/w_wwwroot/n/test_htaccess/mod_rewrite.php?w=cheer&wb=time
?w=cheer&wb=time
*/ /*
D:\wamp64\bin\apache\apache2.4.18\conf #
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory> */ /*
D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess
新建 .htaccess #2016/8/13-11:11
<IfModule mod_rewrite.c>
#the .htaccess file mustfirst check for the module and turn on the rewrite engine:
RewriteEngine on
#After enabling the engine, and before the closing IfModule tag, you add rules dictating the rewrites.
#The syntax is RewriteRule match rewrite
RewriteRule w.php dearchild.php
RewriteRule ^rewrite_ok/\wzero/\wfirst$ mod_write.php?w=$1&wb=$2
</IfModule> apache无法启动-0
#2016/8/13-11:04
<Directory 'D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess' />
AllowOverride All
<Directory>
apache无法启动-1
#2016/8/13-11:04
<Directory 'D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess' />
AllowOverride All
</Directory>
apache无法启动-2
#2016/8/13-11:04
<Directory "D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess" />
AllowOverride All
<Directory>
apache启动
#2016/8/13-11:04
<Directory "D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess">
AllowOverride All
<Directory>
TOOLS- Check http.conf syntax 逐步排错 */ /*
D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess\w.php
任意
D:\wamp64\www\0613pm\w_wwwroot\n\test_htaccess\dearchild.php
<?php
echo 'dear_child_w';
http://localhost/0613pm/w_wwwroot/n/test_htaccess/w.php */
echo 'dear_child_w';//dear_child_w
//验证通过
/*
RewriteRule somepage.php otherpage.php
With that code, any time a user goes to somepage.php, the user will be shown the contents ofotherpage.php, although the browser will still display somepage.php in the address bar.
To be clear, that’s not actually a good use of mod_rewrite, as a literal redirection could beaccomplished with the less complex mod_alias module instead. However, a line like that doesrepresent an easy way to test that mod_rewrite is working.
*/ /*
http://localhost/0613pm/w_wwwroot/n/test_htaccess/mod_write.php?w=wchild&wb=wchildb
Not Found The requested URL /0613pm/w_wwwroot/n/test_htaccess/mod_write.php was not found on this server. Apache/2.4.18 (Win64) PHP/5.6.19 Server at localhost Port 80 */ /*
http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/wzero/wfirst
Not Found The requested URL /0613pm/w_wwwroot/n/test_htaccess/mod_write.php was not found on this server. Apache/2.4.18 (Win64) PHP/5.6.19 Server at localhost Port 80 #2016/8/13-11:44
<IfModule mod_rewrite.c>
#the .htaccess file mustfirst check for the module and turn on the rewrite engine:
RewriteEngine on
#After enabling the engine, and before the closing IfModule tag, you add rules dictating the rewrites.
#The syntax is RewriteRule match rewrite
RewriteRule w.php dearchild.php
RewriteRule ^rewrite_ok/\wzero/\wfirst$ mod_rwrite.php?w=$1&wb=$2
</IfModule> http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/wzero/wfirst ?w=&wb=
//get空,继续修正
*/ /*
#2016/8/13-11:57
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule w.php dearchild.php
RewriteRule ^rewrite_ok/\w{1,}/\w{1,}$ mod_rewrite.php?w=$1&wb=$2
</IfModule> http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/sd
//?w=&wb= #2016/8/13-11:58
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule w.php dearchild.php
RewriteRule ^rewrite_ok/(\w{1,})/(\w{1,})$ mod_rewrite.php?w=$1&wb=$2
</IfModule> http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/sd
//?w=2er32&wb=sd 进一步研究-0
http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32
//Not Found The requested URL /0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32 was not found on this server. Apache/2.4.18 (Win64) PHP/5.6.19 Server at localhost Port 80 进一步研究-1
http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/t/
//Not Found The requested URL /0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/t/ was not found on this server. Apache/2.4.18 (Win64) PHP/5.6.19 Server at localhost Port 80 考虑用户习惯,优化正则, #2016/8/13-12:05
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule w.php dearchild.php
RewriteRule ^rewrite_ok/(\w{1,})/(\w{1,})/{0,}$ mod_rewrite.php?w=$1&wb=$2
</IfModule> http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/t/
//?w=2er32&wb=t a-beautiful-world #2016/8/13-12:07
<IfModule mod_rewrite.c>
RewriteEngine on
#The syntax is RewriteRule match rewrite
RewriteRule w.php dearchild.php
RewriteRule ^rewrite_ok/(\w{1,})/(\w{1,})/{0,}/a-beautiful-world$ mod_rewrite.php?w=$1&wb=$2
</IfModule>
*/
http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/ta-beautiful-world
//Not Found The requested URL /0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/ta-beautiful-world was not found on this server. Apache/2.4.18 (Win64) PHP/5.6.19 Server at localhost Port 80 http://localhost/0613pm/w_wwwroot/n/test_htaccess/rewrite_ok/2er32/t/a-beautiful-world
//?w=2er32&wb=t

//Search Engine Optimization

The modularized site as written has a number of benefits, starting with the fact that it will be easier to maintain and expand as needed.
//模块化站点 维护 扩展
 
 
mod_rewrite is a tool that lets you instruct the server that when the user goes to one URL, the server should provide another resource.
mod_rewrite makes use of regular expressions, so the matching pattern and resulting actual URL can be as complex as needed.
 
Two ways to change Apache's behavior
0-edit the primary Apache configuration file
1-create directory-specific files
// 全局配置文件 目录相关文件
 
The primary configuration file is httpd.conf, found within a conf directory, and it dictates how the entire Apache Web server runs(where the httpd.conf file is on your system will depend on many things). An .htaccess file(pronounced “H-T access”) is placed within a Web directory and is used to affect how Apache behaveswithin just that folder and subfolders.Generally speaking, it’s preferable to make changes in the httpd.conf file, since this file needs to be read only by the Web server each time the server is started. Conversely, .htaccess files must be readby the Web server once for every request to which an .htaccess file might apply. For example, if youhave www.example.com/somedir/.htaccess, any request to www.example.com/somedir/whatever requires reading the .htaccess file, as well as reading an .htaccess file that might exist in www.example.com/. On the other hand, in shared hosting environments, individual users are not allowed to customize the entire Apache configuration, but they may be allowed to use .htaccess to make changes that only affect their sites. And changes to the primary configuration file do require restarting Apache to take effect.
 
 发问:
0-references to external resources cheated the browser! Much more we can do! 
 

Improved SEO with mod_rewrite的更多相关文章

  1. 使用Prerender.io为angular项目做SEO

    现在的项目的为了更好的分工明确,降低耦合都开始采用前后端分离的形式进式开发,我们也采用这种开发形式,前端用angular开发.虽说刚开始也遇各种坑,但是后期熟悉了之后简直爽呆.一个比较大的坑就是SEO ...

  2. ThinkPHP的URL重写+路由+伪静态,实现SEO效果。

    1.URL重写,隐藏网址中的Index.php. ThinkPHP 作为 PHP 框架,是单一入口的,那么其原始的 URL 便不是那么友好.但 ThinkPHP提供了各种机制来定制需要的 URL 格式 ...

  3. ASP.NET的SEO:正则表达式

    目前国内主流的网站内容管理系统中,有大部分是可以将动态的PHP.ASP.ASPX等文档直接生成HTML的.但是由于有些网站的内容较多,因此如果单纯的采取直接生成的方式,将会占用大量的服务器资源.在这种 ...

  4. SEO教程:向百度要流量 第一季

    首先祝贺你:当你看到这篇文章时,你已经站在一条通往SEO达人捷径的路口. 笔者也是今年年初才成为SEOer的一员,在做SEO的过程中,有不少自己独特的心得体会,所以一直酝酿着写一个SEO系列的文章,将 ...

  5. seo一些相关内容

    PR值算法原理总体上基于下面2个前提: 1.一个网页被多次引用,则它可能是很重要的: 一个网页虽然没有被多次引用,但是被重要的网页引用,则它也可能是很重要的:一个网页的重要性被平均的传递到它所引用的网 ...

  6. 301重定向方法大全及SEO中网址规范化,看着不错先收下

    301重定向方法大全及SEO中网址规范化 现在大多数网站都存在一些内容相同但网址(URL)不一样的重复内容,这些重复的内容对于搜索引擎来说却可能被认为是复制网页,复制网页虽然不会被惩罚但因多个网址存在 ...

  7. thinkphp之url的seo优化

    1.网站url做seo优化的原因 SEO是由英文Search Engine Optimization缩写而来, 中文意译为“搜索引擎优化”.SEO是指通过对网站进行站内优化(网站结构调整.网站内容建设 ...

  8. SEO中常用的301永久重定向代码大全

    301是永久重定向的意思,表示请求的网页已永久移动到新位置,服务器返回此响应(对 GET 或 HEAD 请求的响应)时,会自动将请求者转到新位置.其实301重定向在SEO中被广泛应用,也是被广泛认为比 ...

  9. 【微信SEO】公众号也能做排名?

    [写于2016年8月] 最近,微信团队发出一则公告,开放公众号运营者一年内更改公众号名一次,这对不少名字起的奇葩名字(包括dkplus)的公众号来说是一件好事. 为什么说是好事呢?公众号名字直接关联到 ...

随机推荐

  1. struts2:struts.properties配置文件介绍及常量加载顺序

    1. 背景 struts2框架中有两个核心配置文件,其中struts.xml文件主要负责管理应用中的action映射,以及该action包含的result定义等.除此之外,struts2框架还包括一个 ...

  2. 服务端怎样暴露IBinder接口对象

    服务端怎样暴露IBinder接口对象: package com.example.mydownload; import android.app.Service; import android.conte ...

  3. Spring Boot 2.0 返回JSP页面实战

    1. 模板引擎JSP的限制 在开始之前呢,我觉得我们有必要先去了解下 Spring Boot 2.0 官方文档中提到的如下内容: 模板引擎 除了REST Web服务之外,还可以使用Spring MVC ...

  4. IOS SDK -UITableView的奇葩特性

    UITableView是IOS提供的一个带有复用机制的滚动表格,目前的基本功能就是垂直的表格,可以有多个section,每个section可以有多个row,然后还包含有sectionview,foot ...

  5. 《深入应用C++11:代码优化与工程级应用》勘误表

    <深入应用C++11:代码优化与工程级应用>勘误表,会不断更新,欢迎读者留言或发邮件(cpp11book@163.com)给我提出宝贵意见. 1.第7.3节目录final和override ...

  6. asp.net Request、Request.Form、Request.QueryString的区别(转)

    Request.Form:获取以POST方式提交的数据. Request.QueryString:获取地址栏参数(以GET方式提交的数据). Request:包含以上两种方式(优先获取GET方式提交的 ...

  7. 【30集iCore3_ADP出厂源代码(ARM部分)讲解视频】30-6底层驱动之多路开关选择器

    视频简介:该视频介绍iCore3应用开发平台中多路开关选择器的应用,多路开关选择器的硬件电路连接以及软件实现的方法. 源视频包下载地址:链接:http://pan.baidu.com/s/1geQ4W ...

  8. Javascript模版引擎简介

    回顾 Micro-Templating 出自John Resig 2008年的一片文章,以及其经典实现: // Simple JavaScript Templating // John Resig - ...

  9. 不平衡学习 Learning from Imbalanced Data

    问题: ICC警情数据分类不均,30+分类,最多的分类数据数量1w+条,只有10个类别数量超过1k,大部分分类数量少于100条. 解决办法: 下采样:通过非监督学习,找出每个分类中的异常点,减少数据. ...

  10. Android——RecycleView

    RecycleView设置点击事件 http://blog.csdn.net/guxiao1201/article/details/40423361