問題描述
我將 WordPress 安裝移動到 Windows 上的新文件夾/IIS 服務器.我正在 PHP 中設置 301 重定向,但它似乎不起作用.我的帖子 URL 具有以下格式:
I moved a WordPress installation to a new folder on a Windows/IIS server. I'm setting up 301 redirects in PHP, but it doesn't seem to be working. My post URLs have the following format:
http:://www.example.com/OLD_FOLDER/index.php/post-title/
我不知道如何獲取 URL 的 /post-title/
部分.
I can't figure out how to grab the /post-title/
part of the URL.
$_SERVER["REQUEST_URI"]
- 每個人似乎都推薦 - 返回一個空字符串.$_SERVER["PHP_SELF"]
只是返回 index.php
.這是為什么,我該如何解決?
$_SERVER["REQUEST_URI"]
- which everyone seems to recommend - is returning an empty string. $_SERVER["PHP_SELF"]
is just returning index.php
. Why is this, and how can I fix it?
推薦答案
也許,因為你在 IIS 下,
Maybe, because you are under IIS,
$_SERVER['PATH_INFO']
是您想要的,基于您用來解釋的網址.
is what you want, based on the URLs you used to explain.
對于 Apache,您將使用 $_SERVER['REQUEST_URI']
.
For Apache, you'd use $_SERVER['REQUEST_URI']
.
這篇關于如何在 Windows/IIS 服務器上獲取當前頁面的完整 URL?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!