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 Quote Link to comment 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... ?> Quote Link to comment 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 Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.