ginger44 Posted January 15, 2007 Share Posted January 15, 2007 This is what I'm trying to do...I have a JSP page that I want to be accessed by being redirected.Lets call this JSP page http://www.whatever.jsp?whatsup8I was wondering, with PHP, is it possible to somehow just redirect the http://www.whatever.jsp? part and still be able to include the whatsup8 with the new redirected URL at the end.Example:The redirector page will be http://www.redirect.phpI will then place it as http://www.redirect.phpwhatsup8 or something like that and it will go to http://www.whatever.jsp?whatsup8 with redirect.php being the redirector.I have many whatsup pages with different numbers, which is why I'm trying to do this. Any help will be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 15, 2007 Share Posted January 15, 2007 I *think* I understand you. Try this:[code]<?php if (isset($_GET) && key($_GET)!="") { header("http://www.whatever.jsp?".key($_GET)); } else { echo "No parameter on the query string."; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 15, 2007 Share Posted January 15, 2007 If his solution doesn't work (which it probably will), you could try CURL.As far as I know JSP, and PHP both have support for CURL, atleast I think JSP does. Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted January 15, 2007 Share Posted January 15, 2007 As well intentioned as he is being you don't really want cURL in this situation. Quote Link to comment Share on other sites More sharing options...
ginger44 Posted January 15, 2007 Author Share Posted January 15, 2007 What am I supposed to do with that code? I tried saving it as a php file, so it looks like:http://www.redirect.phpwhatsup88Am I doing something wrong? Quote Link to comment Share on other sites More sharing options...
Zoud Posted January 15, 2007 Share Posted January 15, 2007 Shouldn't it look like this?http://www.redirect.php?whatsup88 Quote Link to comment Share on other sites More sharing options...
ginger44 Posted January 15, 2007 Author Share Posted January 15, 2007 Tried that as well, didn't work Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 15, 2007 Share Posted January 15, 2007 You should save that as a PHP page named: "redirect.php". You would then type into your browser the following "http://www.domain.com/redirect?whatsup88".Whatever "parameter" you enter after the question mark will be appended to the end of the jsp page that you are calling. Quote Link to comment Share on other sites More sharing options...
ginger44 Posted January 15, 2007 Author Share Posted January 15, 2007 Nope, that didnt work either. You're missing the .php after redirect in that code. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 15, 2007 Share Posted January 15, 2007 [quote author=ginger44 link=topic=122500.msg505562#msg505562 date=1168899952]Nope, that didnt work either. You're missing the .php after redirect in that code.[/quote]Ok, I'm trying to help you here. Your original question was not very clear and I did my best to interpret it. My code does "exactly" what I stated it does. You stated that you wanted to redirect to a jsp page, so whay do I need to put php in the redirect code.In your original question you stated you wanted the following pages: http://www.redirect.php & http://www.whatever.jsp. Those aren't valid pages because there is no DOMAIN and php and jsp are not TLDs. So, I assumed you meant http://www.domain.com/redirect.php.Anyway, if you saved the code above as a file named redirect.php and you placed it in the root of your website, then typing in http://www.yourdomain.com?123456 would redirect you to http://yourdomain.com/whatever.jsp?123456is that not what you wanted? If not, please explain exactly what you want. Quote Link to comment Share on other sites More sharing options...
ginger44 Posted January 17, 2007 Author Share Posted January 17, 2007 Yes and that didn't work. Is it because the URL I'm trying to be redirected isn't from my domain? Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted January 17, 2007 Share Posted January 17, 2007 I don't know much about curl yet, so you probably want to take his advice. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 You're trying to have a page on someone else's domain redirect to your site?OMG HAX! Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 17, 2007 Share Posted January 17, 2007 [quote author=ginger44 link=topic=122500.msg506648#msg506648 date=1169008000]Yes and that didn't work. Is it because the URL I'm trying to be redirected isn't from my domain?[/quote]If you are trying to redirect TO an external site, then that is possible (in fact I tested my code by having it redirect to Yahoo). If you want to have an external site redirected to your site, then, uh, how should I put this: NO! Quote Link to comment Share on other sites More sharing options...
ginger44 Posted January 17, 2007 Author Share Posted January 17, 2007 No, my site redirected to their site, not the other way around... Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 17, 2007 Share Posted January 17, 2007 Well, I don't know what to tell you. I tested it and it works. As I said I built the solution based upon my interpretation of your requirements. I made assumptions where your requirements were obviously incorrect (e.g. the domain names). If you want to give a clear example of your exact needs I can help further.For example:[color=orange][i]I want that when the user types in http://www.mydomain.com/redirect.php?somecode that they are redirected to http://www.differentdomain.com/somepage.jsp?somecode[/i][/color]That is what I had interpreted and coded for. 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.