重写与htaccess的规则,重定向301 [英] Rewrite rule with htaccess, redirect 301

查看:155
本文介绍了重写与htaccess的规则,重定向301的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想执行这个规则:

RewriteRule ^featured$ home.php?featurez=1 [L,NC,PT,R=301]

但我得到的是:

But what I get is:

http://apps.com/var/www/vhosts/apps.com/httpdocs/iphone/home.php?featurez=1

我试图与PT标签战胜它......但没有上有:(效果..什么问题,如何解决这个问题呢。

I tried to overcome it with PT tags...but nothing has an effect on it :(..whats the problem and how do I solve it..

推荐答案

当你离开过你的规则的目标的斜线,当Apache需要猜测的路径是否是一个URI路径或文件路径,猜测错误。你可以帮助阿帕奇了通过添加一个斜线(或使目标的绝对URI)或添加重写基地:

When you leave off the leading slash in your rule's target, when apache needs to guess whether the path is a URI path or a file path, it guesses wrong. You can help apache out by either adding a leading slash (or making the target an absolute URI) or adding a rewrite base:

RewriteBase /iphone/
RewriteRule ^featured$ home.php?featurez=1 [L,NC,PT,R=301]

(或任何基本URI是你的要求)

(or whatever the base URI is for your request)

或改变目标绝对URI:

Or change the target to an absolute URI:

RewriteRule ^featured$ /iphone/home.php?featurez=1 [L,NC,PT,R=301]

这是假设你的htaccess文件坐在目录iphone您的文档根目录里,并访问你去 HTTP重定向://your.domain/iphone/featured 。否则,刚刚摆脱所有的 iPhone / 的东西。

This is assuming your htaccess file is sitting in the directory "iphone" inside your document root, and to access the redirect you go to http://your.domain/iphone/featured. Otherwise, just get rid of all the iphone/ stuff.

这篇关于重写与htaccess的规则,重定向301的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆