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. IOS开发 文件路径

    1.开发平台路径: /Developer/Platforms 此路径下一般有三个目录,分别是mac电脑.模拟器.iphone真机 MacOSX.platform iPhoneSimulator.pla ...

  2. Spring Boot 应用 发布到Docker

    Spring Boot 应用 先把命令行切换到Maven项目的根目录 E:\gitCode\galaxyguardians 通过mvn clean package命令打包应用程序 ,在E:\gitCo ...

  3. 小米手机安装mitmproxy证书

    [本文出自天外归云的博客园] 问题描述 小米手机在连接mitmproxy代理后通过浏览器访问mitm.it下载android证书后无法成功安装证书 设备:Redmi Note 2(红米手机) 解决方法 ...

  4. app 调用接口

    app 调用接口 /// <summary> /// 是否跳转到活动注册成功页面 /// </summary> /// <returns></returns& ...

  5. 两次内存断点法寻找OEP

    所谓“两次内存断点法寻找OEP”,按照<加密与解密*第三版>上的解释来说,就是这样的.一般的外壳会依次对.text..rdata..data..rsrc区块进行解压(解密)处理,所以,可以 ...

  6. CentOS系统实现SSH无密码登录的方法

    一.环境配置 1.服务端:CentOS release 5.3 IP:222.73.115.198 2.客服端:CentOS release 5.8 IP:192.168.4.244 二.配置SSH无 ...

  7. 程序-代写(qq:928900200)

    CS 310 Programming Assignment 4 Due April 27, 2014 5:00 P.M. About 15 years in the future... The Mar ...

  8. Login failed for user 'IIS APPPOOL\ASP.NET v4.0'

    Looks like it's failing trying to open a connection to SQL Server. You need to add a login to SQL Se ...

  9. [UI] 03 - Bootstrap: component

    前言 一.框架体系 Bootstrap 是基于 HTML5.CSS3.JAVASCRIPT. 教程被分为: Bootstrap 基本结构. Bootstrap CSS. Bootstrap 布局组件 ...

  10. react列表数据显示

    react的列表数据一般是用map循环显示的. 使用map注意:map的回调函数为箭头函数时,后面如果加大括号(箭头函数常规编写),必须要有return才可以,如果箭头函数后面没有大括号(箭头函数简写 ...