繁体   English   中英

301将php重定向到html

[英]301 redirects php to html

我环顾四周,似乎无法找到我的问题的答案。

我有一个.htaccess文件,其中列出了网站www.rubbusa.com的所有301重定向

该文件已上传,没有错误,但仅PDF文件正在重定向,php文件未重定向。

不能使用.htaccess文件重定向PHP文件吗? 还是以某种方式写的?

我确实读过您可以在php页面中添加一行重定向代码,但是这些页面已不存在。

请参阅下面的.htaccess文件示例

谢谢大家的支持。

迈克尔

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

要从.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