PHP, રીડાયરેક્ટ

PHP, પૃષ્ઠથી URL પર રીડાયરેક્ટ કરો. PHP 301 રીડાયરેક્ટ.

આ PHP રીડાયરેક્શન એ HTTP પ્રતિસાદ સ્થિતિ કોડ પાછો આપવો જોઈએ: 301 કાયમ માટે ખસેડવામાં.

જૂના એન્જિનથી નવા URL પર પૃષ્ઠ ક્રમ સ્થાનાંતરિત કરવા માટે શોધ એંજીન્સ 301 પ્રતિસાદ સ્થિતિ કોડનો ઉપયોગ કરે છે.

PHP, હેડર રીડાયરેક્ટ

જુના-પેજ.એફપી કોડને રીડાયરેક્શન કોડથી નવા પેજ.એફપીપી પર બદલો.

old-page.php:

<?php
// PHP permanent URL redirection
header("Location: http://www.domain.com/new-page.php", true, 301);
exit();
?/

જૂના પૃષ્ઠમાં. Php ફાઇલ એક્સ્ટેંશન હોવું આવશ્યક છે.

નવું પૃષ્ઠ કોઈપણ એક્સ્ટેંશન સાથે હોઈ શકે છે.

PHP, રીડાયરેક્ટ ઉદાહરણો

ઉદાહરણ # 1

php-redirect-test.php

<?php
// PHP permanent URL redirection test
header("Location: https://www.rapidtables.org/web/dev/php-redirect.html", true, 301);
exit();
?/

 

આ પૃષ્ઠ પર પાછા php-redirect-test.php માંથી રીડાયરેક્ટ કરવા માટે આ લિંકને દબાવો :

 

PHP, પુનirectદિશામાન પરીક્ષણ - PHP ફાઇલ

ઉદાહરણ # 2

php-redirect-test.htm

<?php
// PHP permanent URL redirection test
header("Location: https://www.rapidtables.org/web/dev/php-redirect.html", true, 301);
exit();
?/

 

એચટીએમએલ ફાઇલથી પીએચપી રીડાયરેક્શન php-redirect-test.htm સામાન્ય રીતે .html ફાઇલ એક્સ્ટેંશનને કારણે કામ કરશે નહીં, સિવાય કે તે .htaccess અથવા httpd.conf ફાઇલમાં સક્ષમ ન હોય :

 

PHP, પુનirectદિશામાન પરીક્ષણ - એચટીએમએલ ફાઇલ

 

HTML ફાઇલોમાં PHP ને સક્ષમ કરવા માટે આ કોડને .htaccess અથવા httpd.conf ફાઇલમાં ઉમેરો:

Addtype application/x-httpd-php .htm .html

 

URL રીડાયરેક્શન ►

 


આ પણ જુઓ

Advertising

વેબ વિકાસ
ઝડપી ટેબલ્સ