<?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>浮山狼de博客 &#187; URL重定向</title>
	<atom:link href="https://www.fushanlang.com/tag/url-rewrite/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fushanlang.com</link>
	<description>next station - 下一站，活在当下，且行且思</description>
	<lastBuildDate>Sat, 29 Nov 2014 15:14:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.5</generator>
	<item>
		<title>htaccess实现子目录指向主域名</title>
		<link>https://www.fushanlang.com/htaccess-to-achieve-a-subdirectory-to-the-main-domain-name-48/</link>
		<comments>https://www.fushanlang.com/htaccess-to-achieve-a-subdirectory-to-the-main-domain-name-48/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 19:12:23 +0000</pubDate>
		<dc:creator><![CDATA[fushanlang]]></dc:creator>
				<category><![CDATA[webserver]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[URL重定向]]></category>

		<guid isPermaLink="false">http://www.fushanlang.com/blog/?p=48</guid>
		<description><![CDATA[今天想为blog加一个重定向，访问主域名直接定向到blog目录，即主域名绑定子目录。之前采用index.html里的 meta和window.location ，好像对SEO不好，而且有明显的转向等待时间。所以搜索了一下其他解决方案。找到如下代码，需要借助 htaccess文件。 # .htaccess main domain to subdirectory redirect # Copy and paste the following code into the .htaccess file # in the public_html folder of your hosting account # make the changes to the file according to the instructions. # Do not change this line. RewriteEngine on # Change yourdomain.com to be your main domain. RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$ # Change &#8216;subdirectory&#8217; to be the directory you will use for your main domain. RewriteCond %{REQUEST_URI} !^/subdirectory/ # Don&#8217;t change this line. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Change &#8216;subdirectory&#8217; to be the directory you will use for your main domain. RewriteRule ^(.*)$ /subdirectory/$1 # Change yourdomain.com to be your main domain again. # Change &#8216;subdirectory&#8217; to be the directory you will use for your main domain # followed by / then the main file for your site, index.php, index.html, etc. RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$ RewriteRule ^(/)?$ subdirectory/index.php [L] .htaccess指向index.php 最末一句使得首页访问yourdomain.com指向 blog的index.php 修改之后，再通过youdomain.com访问会直接跳转（并非URL跳转）到blog目录，如果blog是采用wordpress的话，如果想以后的链接URL中没有/blog/ 的话可以在后台Setting里的General 里修改URL 为youdomain.com,这样绑定就非常完美的完成了。 ]]></description>
				<content:encoded><![CDATA[<div>今天想为blog加一个重定向，访问主域名直接定向到blog目录，即主域名绑定子目录。之前采用index.html里的 meta和window.location ，好像对SEO不好，而且有明显的转向等待时间。所以搜索了一下其他解决方案。找到如下代码，需要借助</div>
<div>htaccess文件。</div>
<li># .htaccess main domain to subdirectory redirect</li>
<li># Copy and paste the following code into the .htaccess file</li>
<li># in the public_html folder of your hosting account</li>
<li># make the changes to the file according to the instructions.</li>
<li># Do not change this line.</li>
<li>RewriteEngine on</li>
<li># Change yourdomain.com to be your main domain.</li>
<li>RewriteCond %{HTTP_HOST} ^(<a href="http://www.)?yourdomain.com$">www.)?yourdomain.com$</a></li>
<li># Change &#8216;subdirectory&#8217; to be the directory you will use for your main domain.</li>
<li>RewriteCond %{REQUEST_URI} !^/subdirectory/</li>
<li># Don&#8217;t change this line.</li>
<li>RewriteCond %{REQUEST_FILENAME} !-f</li>
<li>RewriteCond %{REQUEST_FILENAME} !-d</li>
<li># Change &#8216;subdirectory&#8217; to be the directory you will use for your main domain.</li>
<li>RewriteRule ^(.*)$ /subdirectory/$1</li>
<li># Change yourdomain.com to be your main domain again.</li>
<li># Change &#8216;subdirectory&#8217; to be the directory you will use for your main domain</li>
<li># followed by / then the main file for your site, index.php, index.html, etc.</li>
<li>RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$</li>
<li><span style="color: #ff6600;">RewriteRule ^(/)?$ subdirectory/index.php [L]</span></li>
<li></li>
<div><strong>.htaccess指向index.php </strong>最末一句使得首页访问yourdomain.com指向 blog的index.php</div>
<div>修改之后，再通过youdomain.com访问会直接跳转（并非URL跳转）到blog目录，如果blog是采用wordpress的话，如果想以后的链接URL中没有/blog/ 的话可以在后台Setting里的General 里修改URL 为youdomain.com,这样绑定就非常完美的完成了。</div>
]]></content:encoded>
			<wfw:commentRss>https://www.fushanlang.com/htaccess-to-achieve-a-subdirectory-to-the-main-domain-name-48/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.205 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2026-03-05 06:29:10 -->
