簡體   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