<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Apache Archives - 明成🌻追忆过去，妄想未来</title>
	<atom:link href="https://www.huaweichen.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.huaweichen.com/tag/apache/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Dec 2021 01:17:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>

<image>
	<url>https://www.huaweichen.com/wp-content/uploads/2020/09/cropped-avatar-32x32.png</url>
	<title>Apache Archives - 明成🌻追忆过去，妄想未来</title>
	<link>https://www.huaweichen.com/tag/apache/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">147291541</site>	<item>
		<title>Apache的重定向和伪静态</title>
		<link>https://www.huaweichen.com/apache-mod-rewrite/</link>
		
		<dc:creator><![CDATA[Huawei Chen]]></dc:creator>
		<pubDate>Wed, 22 Sep 2021 10:48:13 +0000</pubDate>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[Apache]]></category>
		<guid isPermaLink="false">https://www.huaweichen.com/?p=2937</guid>

					<description><![CDATA[<p>重定向和伪静态的基本原理和方法 重定向和伪静态的实现方法： 通过.htaccess配置 工作原理： .htaccess文件提供了针对每个目录改变配置的方法。在指定目录中，放置一个.htaccess文件，此文件的作用域实用于当前目录及其所有的子目录。 性能问题： 开启页面的时候要查找所有的上级目录的.htaccess。 例如：/wamp/www/project1/public 文件夹下有.htaccess文件，那么Apache会查找： /wamp/www/project1, /wamp/www, /wamp, / 文件夹下是否有.htaccess。 建议PROD以下的环境，使用.htaccess，生产环境需要把所有的重定向文件写到Apache主配置文件中。 安全问题：允许用户自行修改服务器的配置，且在不需要重启apache的情况下生效。例如，在没有index文件的情况下，很有可能会暴露文件夹下的所有文件。 妥协： 共享服务器，访问量不够大的网站，需要更好的SEO效果的网站，可以妥协掉部分性能。 通过Apache的主配置文件字段 使用PHP等脚本文件实现（仅限外部重定向） 一个基本实例： 开启目录重定向的权限： AllowOverride All 配合 .htaccess 配合调试，不需要重启服务器。在Windows下，用CMD创建.htaccess命令：echo 1 &#62; .htaccess RewriteEngine on 开启mod_rewrite RewriteRule ^(.*)\.htm$ $1.html 当浏览器的URL尝试访问test.htm，Apache会在此.htaccess文件的当前目录下寻找test.html文件。 Apache重定向原理： https://httpd.apache.org/docs/2.4/images/rewrite_process_uri.png 防止出现死循环。 mod_rewrite 详解 1. 日志功能 LogLevel Apache 2.4+ RewriteLog RewriteLogLevel Apache 2.2 配置：LogLevel alert rewrite:trace8 (LogLevel 不要大于trace2，或者关闭。) 只能在Apache的主配置文件下配置，无法在.htaccess进行配置。 查看：apache_error.log 文件 2. RewriteRule语法 基本格式：RewriteRule 模式（正则匹配） 替换的URL [flags] 模式匹配，支持Perl格式的正则表达式。 rewrite的预设变量和替换模式的匹配结果： $1 多个flag用逗号隔开：[R=302,C] R flag [&#8230;]</p>
<p>The post <a href="https://www.huaweichen.com/apache-mod-rewrite/">Apache的重定向和伪静态</a> appeared first on <a href="https://www.huaweichen.com">明成🌻追忆过去，妄想未来</a>.</p>
]]></description>
		
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2937</post-id>	</item>
	</channel>
</rss>
