defeated Posted June 13, 2008 Share Posted June 13, 2008 Hi, I want to put some 301 redirects into my htaccess file but the redirects are for dynamic pages. Does anybody know if it is possible to write something like the following: Redirect 301 /oldpage.php?* http://www.example.com/newpage.php?* I don't want to break my site. Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/ Share on other sites More sharing options...
wildteen88 Posted June 13, 2008 Share Posted June 13, 2008 You can use mod_rewrite to perform dynamic redirects, example RewriteEngine On RewriteRule oldpage.php/(.+) newpage.php/$1 [NC,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/#findComment-564943 Share on other sites More sharing options...
defeated Posted June 17, 2008 Author Share Posted June 17, 2008 Thanks for that but I'm not sure I entirely follow it. Could you explain what each part does? Do I have to define $1? Or does that code as it is work for everything? (changing the oldpage and newpage paramaters of course). Thanks for your help. If yahoo was any good at keeping up with changes none of this would be necessary, but I'm getting a lot of bounces from them. Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/#findComment-567122 Share on other sites More sharing options...
wildteen88 Posted June 17, 2008 Share Posted June 17, 2008 It should work out fine, just make sure Yahoo supports mod_rewrite. Just change oldpage.php and newpage.php to whatever you want. Don't modify the /(.+) or $1 bits. Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/#findComment-567441 Share on other sites More sharing options...
defeated Posted June 17, 2008 Author Share Posted June 17, 2008 Thank you very much. I'll give it a go tomorrow and see what happens! Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/#findComment-567520 Share on other sites More sharing options...
defeated Posted July 1, 2008 Author Share Posted July 1, 2008 ok, so it took a few more days for me to get around to it. Didn't work. Heres what I did. renamed the .htaccess file by removing the . so that I could view it in my editor. It was an empty when I opened it. I wrote the following. RewriteEngine On RewriteRule jobs.php/(.+) jobs_ireland.php/$1 [NC,R=301] I wrote a few more lines for other pages but exactly the same as the one above. I get 404 not found if I type in www.jackiebrownmedical.ie/jobs.php?url=jobs Where did I go wrong? Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/#findComment-579056 Share on other sites More sharing options...
trq Posted July 1, 2008 Share Posted July 1, 2008 According to your rule you would need to use a url such as www.jackiebrownmedical.ie/jobs.php/jobs but even then its not quite right. Your rule would need to be... RewriteRule jobs.php/(.+) jobs_ireland.php?$1 [NC,R=301] Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/#findComment-579107 Share on other sites More sharing options...
defeated Posted July 5, 2008 Author Share Posted July 5, 2008 Bingo!! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/110034-solved-htaccess-and-php-extensions/#findComment-582223 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.