Apache 301 跳轉的兩種方式

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "F:\workspace\mysite"
	<Directory "F:\workspace\mysite">
		Options Indexes FollowSymLinks
		AllowOverride all
		Order Deny,Allow
		Allow from all
		satisfy all
	</Directory>
	DirectoryIndex index.php index.html index.htm
    ServerName www.mysite.dev
	ServerAlias mysite.dev
    ErrorLog "logs/mysite.dev-error.log"
    CustomLog "logs/mysite.dev-access.log" common
	RewriteEngine On
	Options +FollowSymLinks
	#這是第一種方法,但是這句是不正確的,因爲301跳轉不能是動態地址,也就是不能帶問號。
	RedirectMatch 301 ^/test.php\?id=(.*)$ /test2.php?i2?3d=$1
	#這是第二種方法了。
	RewriteCond %{HTTP_HOST} ^mysite\.dev [NC]
	RewriteRule ^(.*)$ http://www.mysite.dev$1 [R=301,NC]
</VirtualHost>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章