Htaccess 从 /example 重定向到 /folder/example.php
我想为我正在工作的网站上的几个页面创建一些临时重定向。
我想像这样302
重定向:
从:site.com/example1/
到:site.com/folder/example1.php
来自:site.com/example2/
到:site.com/folder/example2.php
该网站是基于wordpress的,我最近在/中添加了一个迷你网站包含静态 php 文件的文件夹/。我知道这是一个奇怪的重定向,但有一段时间我想为访问者提供一些替代内容。
我的问题是当我使用时:
Redirect 302 /about/ http://site.com/ folder/about.php
当我访问 site.com/about/
链接时,我被重定向到 site.com/folder/about.php/
尾部斜杠导致样式表无法正确加载。
我很感激任何建议
I would like to create some temporary redirects for a few pages on a website I'm working.
I'd like to 302
redirect like this:
From: site.com/example1/
To: site.com/folder/example1.php
From: site.com/example2/
To: site.com/folder/example2.php
The site is based on wordpress, and I recently add a mini-site into /folder/ that has static php files. I know it's an odd redirection, but for a while I'd like serve the visitors with some an alternative content.
My problem is when I'm using:
Redirect 302 /about/ http://site.com/folder/about.php
When I access the site.com/about/
link I get redirected tosite.com/folder/about.php/
The trailing slash causes for stylesheets not to be loaded correctly.
I'd appreciate any suggestion
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不完全确定你想在这里做什么,所以这里是 302 重定向的语法。
这是假设文件页面的顶部有重定向。
http://php.net/manual/en/function.header.php
I am not entirely sure what you're trying to do here so here is the syntax for a 302 Redirect.
This is assuming file page will have the redirect at the top.
http://php.net/manual/en/function.header.php
嗯...您要更改域名吗?试试这个:
Redirect 302 /about/ /folder/about.php
它适用于我刚才处理的示例。希望它对你有用。Hmm... are you changing the domain at all? Try this:
Redirect 302 /about/ /folder/about.php
It worked on the example I worked up just a moment ago. Hopefully it will work for you.http://corz.org/serv/tricks/htaccess2.php
在此网站上,您会发现使用 .htaccess 文件创建 URL 重定向的有用提示
http://corz.org/serv/tricks/htaccess2.php
on this website, you`ll find useful tips to create URL Redirections using the .htaccess file