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. Eclipse插件的安装(手动安装),以安装SVN插件和中文语言包为例

    Eclipse 插件的手动配置 今天自己亲自手动安装了Eclipse插件,参考了网络上的一些文章,总结一下安装的方法.下面通过两个例子来分享一下自己的收获. 例1:SVN插件安装 1.在Eclipse ...

  2. [docker] macvlan最佳实战

    macvlan和ipvlan的对比 http://hicu.be/macvlan-vs-ipvlan macvlan ipvlan 参考: https://yq.aliyun.com/articles ...

  3. [k8s]jenkins部署在k8s集群

    $ cat jenkins-pvc.yaml kind: PersistentVolumeClaim apiVersion: v1 metadata: name: jenkins-pvc spec: ...

  4. mongodb浅析

    设计特征: MongoDB 的设计目标是高性能.可扩展.易部署.易使用,存储数据非常方便.其主要功能特性如下. (1)面向集合存储,容易存储对象类型的数据.在MongoDB 中数据被分组存储在集合中, ...

  5. linux每日命令(25):Linux文件类型与扩展名

    Linux文件类型和Linux文件的文件名所代表的意义是两个不同的概念.我们通过一般应用程序而创建的比如file.txt.file.tar.gz ,这些文件虽然要用不同的程序来打开,但放在Linux文 ...

  6. Centos 6.4 安装erlang&rabbitmq

    1. 安装 erlang 1.1 准备工作,先安装依赖库 yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel openssl-d ...

  7. token令牌和jwt

    用户登录,后端生成token返回给前端 前端拿到token,以后每次登录使用header里的token进行权限验证 后端接收到前端传来的token,如果是通过数据库或redis或session进行比对 ...

  8. Java如何查找系统的代理设置?

    在Java编程中,如何查找系统的代理设置? 以下示例显示如何使用HttpURLConnection类的systemSetting()方法和getResponse()方法的put方法在系统上查找代理设置 ...

  9. docker开源仓库Harbor部署笔记

    Harbor介绍Harbor是Vmvare团队开发的开源企业级registry仓库,相比docker官方拥有更丰富的权限权利和完善的架构设计,适用大规模docker集群部署提供仓库服务.项目地址:ht ...

  10. history 命令历史

    在终端中按捉[Ctrl]键的同时[r]键,出现提示:(reverse-i-search),此时你尝试一下输入你以前输入过的命令,当你每输入一个字符 的时候,终端都会滚动显示你的历史命令.当显示到你想找 ...