hakmir Posted November 26, 2008 Share Posted November 26, 2008 is it possible that one php file will redirect all the requested pages like this: for example when people type these addresses it will first go to redirect.php then depends on what they type after www.yoursite.com, it will redirect those pages. www.yoursite.com/firstpage www.yoursite.com/secondpage www.yoursite.com/thirdpage I know that for every request you can make a separate page but I just want one page to redirect all. Thanks in advance Link to comment https://forums.phpfreaks.com/topic/134318-redirect-from-one-file/ Share on other sites More sharing options...
Third_Degree Posted November 26, 2008 Share Posted November 26, 2008 this is accomplished with .htaccess files. Read up on mod-rewrite. But yes, you will eventually need a simple file like redirect.php with code something like: <?php if ( $_GET["url"] == 'blah' ) die( header( "Location: blah.php" ) ); if ( $_GET["url"] == 'blah2' ) die( header( "Location: blah2.php" ) ); //Etc... ?> Link to comment https://forums.phpfreaks.com/topic/134318-redirect-from-one-file/#findComment-699291 Share on other sites More sharing options...
hakmir Posted November 26, 2008 Author Share Posted November 26, 2008 I'll check it. Thanks a lot Link to comment https://forums.phpfreaks.com/topic/134318-redirect-from-one-file/#findComment-699297 Share on other sites More sharing options...
dezkit Posted November 26, 2008 Share Posted November 26, 2008 this is accomplished with .htaccess files. Read up on mod-rewrite. But yes, you will eventually need a simple file like redirect.php with code something like: <?php if ( $_GET["url"] == 'blah' ) die( header( "Location: blah.php" ) ); if ( $_GET["url"] == 'blah2' ) die( header( "Location: blah2.php" ) ); //Etc... ?> Your current pages are called using index.php with parameter of url i.e http://www.example.com/index.php?url=category and instead of this URL, you want a nice and easy to read URL like http://www.example.com/category Solution - Put the following lines in your .htaccess file. RewriteEngine on RewriteRule ^([^/\.]+)/?$ /index.php?url=$1 [L] Link to comment https://forums.phpfreaks.com/topic/134318-redirect-from-one-file/#findComment-699298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.