简体   繁体   English

301将php重定向到html

[英]301 redirects php to html

I have had a look around and cant seem to find an answer for my question. 我环顾四周,似乎无法找到我的问题的答案。

I have a .htaccess file where I have listed all my 301 redirects for the website www.rubbusa.com 我有一个.htaccess文件,其中列出了网站www.rubbusa.com的所有301重定向

The file has been uploaded with no errors but only the PDF files are redirecting, the php files are not. 该文件已上传,没有错误,但仅PDF文件正在重定向,php文件未重定向。

Can PHP file not be redirected using a .htaccess file? 不能使用.htaccess文件重定向PHP文件吗? or is it written in a certain way? 还是以某种方式写的?

I did read that you can add a line of redirect code in a php page but these pages do not exist anymore. 我确实读过您可以在php页面中添加一行重定向代码,但是这些页面已不存在。

Please see below a little sample of the .htaccess file 请参阅下面的.htaccess文件示例

Thank you all for your support. 谢谢大家的支持。

Michael 迈克尔

DirectoryIndex index.html.var index.htm index.html index.shtml index.xhtml index.wml index.perl index.pl index.plx index.ppl index.cgi index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm index.php5 Default.html Default.htm home.html
RewriteEngine On


Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^rubbusa.com [nc]
rewriterule ^(.*)$ http://www.rubbusa.com/$1 [r=301,nc]

ErrorDocument 404 /error404.htm
Redirect 301 /brochures/Aviation-brochure.pdf http://www.rubbusa.com/brochures/aviation.pdf
Redirect 301 /brochures/Emergency-relief-brochure.pdf http://www.rubbusa.com/brochures/emergency_shelters.pdf
Redirect 301 /brochures/Environmental-brochure.pdf http://www.rubbusa.com/brochures/waste_recycling.pdf

Redirect 301 /bulk-storage-buildings/highlights.php http://www.rubbusa.com/markets/bulk-storage-buildings.htm
Redirect 301 /bulk-storage-buildings/photo-gallery.php http://www.rubbusa.com/photogallery/storage.htm
Redirect 301 /bulk-storage-buildings/projects.php http://www.rubbusa.com/markets/bulk-storage-buildings.htm

To 301 redirect from a .php file you need to send the correct headers: 要从.php文件重定向到301,您需要发送正确的标头:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.New-Website.com");
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM