Dragosvr92 Posted July 5, 2010 Share Posted July 5, 2010 Hey can anyone please write me a script on how to: Change: http://MyWebSite.net/Track.php?ip=AA.BB.CC.DD To: http://MyWebSite.net/Track/AA.BB.CC.DD Thanks Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/ Share on other sites More sharing options...
premiso Posted July 5, 2010 Share Posted July 5, 2010 There are plenty written tutorials out there. Here is one: http://corz.org/serv/tricks/htaccess2.php Please, do not ask people to write stuff for you. If you are willing to pay, post in the freelance. If you need help with a current script ask. But if you are not willing to google / read why should anyone else be willing to do that for you without payment? Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1081617 Share on other sites More sharing options...
Dragosvr92 Posted July 5, 2010 Author Share Posted July 5, 2010 You are right... there are plenty but none worked for me and for your information .... I've Googled so much about it months ago and all i find was non-working bullshit even find a site that generated the script by writing what you need like ?ip= blablah and it didnt worked in the end i did find a script that works partially.... Here it is... : Options +FollowSymLinks -MultiViews RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{QUERY_STRING} ^(.*&)?ip=([^&]+)(&.*)?$ [NC] RewriteRule ^Track.php /Track/%2? [R=301,L] RewriteRule ^Track/([^&]+)$ /Track.php?ip=$1 [L] But its not working right heres how it acts... So you browse to http://MyWebSite.net/Track.php Submit the form and it generates : http://MyWebSite.net/Track/AA.BB.CC.DD i need to set Track.php as Track and be able to browse to Track... anyone has an idea how may i remove its extension and do that ? why should anyone else be willing to do that for you without payment? Because This kind of Script takes a VERY Small amount of time for someone that knows Apache in my opinion And... its a Support Forum when ppls help each other ! not everyone is as greedy as you and asking for payments in exchange of support Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1081632 Share on other sites More sharing options...
trq Posted July 5, 2010 Share Posted July 5, 2010 Your original post would have been much better received if you had posted what you did in your last reply, showing that you have at least made an effort. Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1081635 Share on other sites More sharing options...
Dragosvr92 Posted July 5, 2010 Author Share Posted July 5, 2010 Your original post would have been much better received if you had posted what you did in your last reply, showing that you have at least made an effort. I Wroted that fast ... I thought that it will be too simple for someone who knows Apache to write a few lines of script for that Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1081641 Share on other sites More sharing options...
trq Posted July 5, 2010 Share Posted July 5, 2010 I thought that it will be too simple for someone who knows Apache to write a few lines of script for that It would be, but it wouldn't teach you how to write your own rules which defies the purpose. Wouldn't you rather read a few tutorials and actually learn what you are doing so that next time you don't need to come and ask someone else to do it for you again? Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1081645 Share on other sites More sharing options...
Dragosvr92 Posted July 6, 2010 Author Share Posted July 6, 2010 Well can anyone help me on this please ? Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1082163 Share on other sites More sharing options...
Dragosvr92 Posted August 15, 2010 Author Share Posted August 15, 2010 Bump Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1099470 Share on other sites More sharing options...
Dragosvr92 Posted August 17, 2010 Author Share Posted August 17, 2010 last time i'll ask ... can anyone help me with this ? Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1100430 Share on other sites More sharing options...
wildteen88 Posted August 18, 2010 Share Posted August 18, 2010 The rewrite rule for http://MyWebSite.net/Track/AA.BB.CC.DD Would be RewriteRule Track/([a-z0-9.]+) track.php?ip=$1 [NC,L] To get AA.BB.CC.DD from the url you'd use $_GET['ip'] Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1100849 Share on other sites More sharing options...
Dragosvr92 Posted August 19, 2010 Author Share Posted August 19, 2010 The rewrite rule for http://MyWebSite.net/Track/AA.BB.CC.DD Would be RewriteRule Track/([a-z0-9.]+) track.php?ip=$1 [NC,L] To get AA.BB.CC.DD from the url you'd use $_GET['ip'] hi i appreciate you've replyed but your script dosnt do anything the one i posted here in a previous post works ok in creating http://MyWebSite.net/Track/AA.BB.CC.DD but ONLY When the get form is submitted is there a way to get http://MyWebSite.net/Track/ to point from Track.php to browse directly to http://MyWebSite.net/Track/ without the form beeing submitted Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1101444 Share on other sites More sharing options...
premiso Posted August 21, 2010 Share Posted August 21, 2010 I will help if you remove that stupid ass image out of your signature.... a text link is 10times better and 1000000times LESS annoying. Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1102046 Share on other sites More sharing options...
Dragosvr92 Posted September 3, 2010 Author Share Posted September 3, 2010 wildteen88 Do you know a other way of doing this please ? Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1106979 Share on other sites More sharing options...
wildteen88 Posted September 3, 2010 Share Posted September 3, 2010 Do not be under the assumption mod_rewrite will change your urls for you! It will not automatically change the url form http://MyWebSite.net/track.php?ip=AA.BB.CC.DD to http://MyWebSite.net/Track/AA.BB.CC.DD. It will only map the url http://MyWebSite.net/Track/AA.BB.CC.DD to http://MyWebSite.net/track.php?ip=AA.BB.CC.DD hi i appreciate you've replyed but your script dosnt do anything the one i posted here in a previous post works ok in creating http://MyWebSite.net/Track/AA.BB.CC.DD but ONLY When the get form is submitted is there a way to get http://MyWebSite.net/Track/ to point from Track.php to browse directly to http://MyWebSite.net/Track/ without the form beeing submitted I don't understand what you mean Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1106988 Share on other sites More sharing options...
Dragosvr92 Posted September 3, 2010 Author Share Posted September 3, 2010 well let me try again to explain more clearly I Want to change : http://MyWebSite.net/Track.php To: http://MyWebSite.net/Track And When the Form Submits to Create this link: http://MyWebSite.net/Track/AA.BB.CC.DD NOT http://MyWebSite.net/Track.php?ip=AA.BB.CC.DD Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1106995 Share on other sites More sharing options...
wildteen88 Posted September 3, 2010 Share Posted September 3, 2010 You'll need to use javascript to override the browsers default behaviour of submitting the form to track.php?ip=AA.BB.CC.DD Give your form an id of ip_form and the text input field an id of id. So you form is <form id="ip_form" action="track.php"> <input type="text" name="ip" id="ip" value="" /> <input type="submit" name="submit" value="submit" /> </form> Now place the following code AFTER your form <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $('#ip_form').submit(function() { this.action = '/Track/' + $('#ip').val(); }); </script> This will now make your form submit to site.com/Track/ipadresshere Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1107014 Share on other sites More sharing options...
Dragosvr92 Posted September 4, 2010 Author Share Posted September 4, 2010 Thank You Wild but its not what i want to do... and it isnt working as you are saying For Example the link http://localhost.net/Track/ is getting a 404 error And when i submit the Form it generates http://localhost.net/Track/79.113.108.166?ip=79.113.108.166 but http://localhost.net/Track/79.113.108.166 isnt working also The htaccess Script i posted works almost Fine it only needs to Transform Track.php into Track So you could browse to Track Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1107073 Share on other sites More sharing options...
wildteen88 Posted September 4, 2010 Share Posted September 4, 2010 Change the javascript to <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $('#ip_form').submit(function() { window.location = '/testkiller/Track/' + $('#ip').val(); return false; }); </script> This will be your .htaccess file RewriteEngine On RewriteRule ^Track/([a-z0-9.]+)/?$ track.php?ip=$1 [NC,L] RewriteRule ^Track/?$ track.php [NC,L] Go to http://site.com/Track/. Fill in the form with an ipaddress. It should redirect to http://site.com/Track/AA.BB.CC.DD Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1107078 Share on other sites More sharing options...
Dragosvr92 Posted September 6, 2010 Author Share Posted September 6, 2010 Thanks but it wont work it dos nothing... this site is a example of what i want it to be like ... http://whois.domaintools.com/79.113.108.166 Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1108024 Share on other sites More sharing options...
Dragosvr92 Posted September 6, 2010 Author Share Posted September 6, 2010 i had found this script before i started this topic that works partially.... Options +FollowSymLinks -MultiViews RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{QUERY_STRING} ^(.*&)?ip=([^&]+)(&.*)?$ [NC] RewriteRule ^Track.php /Track/%2? [R=301,L] RewriteRule ^Track/([^&]+)$ /Track.php?ip=$1 [L] This is what it dos ... So you Browse to http://llocalhost/Track.php Submit the GET Form and it Changes the link to : http://llocalhost/Track/79.113.109.162 I Want to browse to http://llocalhost/Track And When i submit the form to create http://llocalhost/Track/79.113.109.162 Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1108029 Share on other sites More sharing options...
Dragosvr92 Posted September 8, 2010 Author Share Posted September 8, 2010 Wild Could you still help ? Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1108508 Share on other sites More sharing options...
wildteen88 Posted September 8, 2010 Share Posted September 8, 2010 Try out the following RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{REQUEST_URI} track\.php$ [NC,OR] RewriteCond %{QUERY_STRING} ip\=([^&]+)(&.*)?$ [NC] RewriteRule . Track/%1? [NC,R,L] RewriteRule ^Track/([a-z0-9.]+)/?$ track.php?ip=$1 [NC,L] RewriteRule ^Track/?$ track.php [NC,L] If you go to site.com/track.php it should redirect you to sitre.com/Track/ Submitting the form will go to site.com/Track/AA.BB.CC.DD Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1108517 Share on other sites More sharing options...
Dragosvr92 Posted September 8, 2010 Author Share Posted September 8, 2010 Thank You !! That Works as i wanted it only has a very small bug When i browse to http://localhost/Track.php it redirects me to http://localhost/home/USER/domains/wheresmyip.net/public_html/Track/ and not http://localhost/Track.php The rest Works as it should .. Browsing to Track And adding the IP after is working fine Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1108665 Share on other sites More sharing options...
Dragosvr92 Posted September 8, 2010 Author Share Posted September 8, 2010 Also i just noticed that the Script wont Work on my Windows machine it gives this error in the apache error log [Wed Sep 08 17:05:47 2010] [alert] [client 127.0.0.1] C:/wamp/www/IP/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration, referer: http://localhost/ And this on the page Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. On my Linux Hosting place it works fine Do i need to add/activate a module or something ? Edit: i came around this http://www.webmasterworld.com/forum92/925.htm and activated the rewrite_module and it wont show that error again .... and i can browse to Track but on submit it submits to http://localhost/C:/wamp/www/IP/Track/ Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1108669 Share on other sites More sharing options...
wildteen88 Posted September 8, 2010 Share Posted September 8, 2010 Change RewriteRule . Track/%1? [NC,R,L] to RewriteRule . /Track/%1? [NC,R,L] Quote Link to comment https://forums.phpfreaks.com/topic/206812-htaccess-url-rewrite/#findComment-1108692 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.