Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess重定向与重定向匹配_.htaccess_Redirect - Fatal编程技术网

.htaccess htaccess重定向与重定向匹配

.htaccess htaccess重定向与重定向匹配,.htaccess,redirect,.htaccess,Redirect,我正在将301重定向添加到我的网站,以下是htaccess内容: RedirectMatch ^/gift/birthday/(.*) /gifts.html 我的浏览器中的结果是: http://www.website.com/gifts.htmlbirthday/ 我想: http://www.website.com/gifts.html 我该怎么做 编辑:我的访问权限是: <IfModule mod_rewrite.c> Options +Fo

我正在将301重定向添加到我的网站,以下是htaccess内容:

    RedirectMatch ^/gift/birthday/(.*) /gifts.html
我的浏览器中的结果是:

    http://www.website.com/gifts.htmlbirthday/ 
我想:

    http://www.website.com/gifts.html
我该怎么做

编辑:我的访问权限是:

<IfModule mod_rewrite.c>

Options +FollowSymLinks
RewriteEngine on

RewriteRule ^api/rest api.php?type=rest [QSA,L]

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_METHOD} ^TRAC[EK]
RewriteRule .* - [L,R=405]

RewriteCond %{REQUEST_URI} !^/(media|skin|js)/


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule .* index.php [L]

RedirectMatch ^/gift/birthday/(.*) /gifts.html
</IfModule>

选项+FollowSymLinks
重新启动发动机
重写规则^api/restapi.php?type=rest[QSA,L]
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
RewriteCond%{REQUEST_METHOD}^TRAC[EK]
重写规则。*-[L,R=405]
重写cond%{REQUEST_URI}^/(媒体|皮肤| js)/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-L
重写规则。*index.php[L]
重定向匹配^/gift/birth/(.*)/gifts.html
不要像这样混合使用mod_重写规则和mod_别名指令,它们不是按照.htaccess的顺序处理的,而是单独处理的,因为它们由不同的apache模块处理

你需要的是这样的东西:

# this is not mod_rewrite rule so it can be outside the IfModule
Options +FollowSymLinks

# all mod_rewrite rules go here
<IfModule mod_rewrite.c>

# initialize mod_rewrite
RewriteEngine on
RewriteBase /

# your redirect
RewriteRule ^gift/birthday/  http://www.website.com/gifts.html [R=301,L]

# copy&paste the rest of your htaccess below, just delete that RedirectMatch line
# ...
#这不是mod_重写规则,因此它可以在ifu模块之外
选项+FollowSymLinks
#所有mod_重写规则都在这里
#初始化mod_重写
重新启动发动机
重写基/
#你的重定向
重写规则^礼物/生日/http://www.website.com/gifts.html [R=301,L]
#复制并粘贴下面htaccess的其余部分,只需删除该匹配行即可
# ...
此重写规则将301从任何以gift/birth/开头的url重定向到固定的url/gifts.htm。字母[L]表示如果此规则匹配,则跳过其余规则


不要忘记在结尾处用关闭规则集。

这是您的htaccess文件中唯一的规则吗?请尝试清理浏览器缓存。不,这不是唯一的规则,请参阅上面的my htaccess。(我已经清理了缓存)