重写与htaccess的规则,重定向301

编程入门 行业动态 更新时间:2024-10-21 05:44:36
本文介绍了重写与htaccess的规则,重定向301的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想执行这个规则:

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

但我得到的是:

But what I get is:

apps/var/www/vhosts/apps/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 your.domain/iphone/featured. Otherwise, just get rid of all the iphone/ stuff.

更多推荐

重写与htaccess的规则,重定向301

本文发布于:2023-11-01 18:16:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550055.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   重定向   规则   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!