auto fix domain names

  • Borrow -A- Geek
  • Professor
  • Professor
  • User avatar
  • Posts: 763
  • Loc: Dallas/Ft Worth, Texas

Post 3+ Months Ago

check this nice little snippet... you know how you go to google or yahoo etc and type it all funk like

http://GOOgle.coM or http://YAHOO.com ?? well this little code will cange it to

http://www.google.com/ and http://www.yahoo.com/

Code: [ Select ]
<script language=javascript>
if(document.domain.toLowerCase().replace("www.","")!="google.com".toLowerCase().replace("www.","")){
location="about:blank";

}
</script>
  1. <script language=javascript>
  2. if(document.domain.toLowerCase().replace("www.","")!="google.com".toLowerCase().replace("www.","")){
  3. location="about:blank";
  4. }
  5. </script>


someone comment if im wrong lol... but that what i get from that code...
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

First question,

Where would you use this at? Like on your webpage so that if people type your domain in all weird it will fix it? Or is this just a nice example of how you can change the case of text? :)

Anyway for the little snipplet it probably isn't necessary to have the toLowerCase() function and replace() function on the string "google.com" since you already wrote it the way you want. So in other words you could make the script do the exact same thing with a bit simplier code like:

Code: [ Select ]
<script language=javascript>
if(document.domain.toLowerCase().replace("www.","")!="google.com")){
location="about:blank";

}
</script>
  1. <script language=javascript>
  2. if(document.domain.toLowerCase().replace("www.","")!="google.com")){
  3. location="about:blank";
  4. }
  5. </script>
  • Borrow -A- Geek
  • Professor
  • Professor
  • User avatar
  • Posts: 763
  • Loc: Dallas/Ft Worth, Texas

Post 3+ Months Ago

good point... that was a copy and paste job by the way hehe... so i wasnt entirely 100% sure of all of its functions..
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

where to put it, would have been my question too. Would be interesting
to see more info on this. I've wondered about this myself.

Also, I've wondered how when I go to a site typing in http://www.domain.com
it then removes the www and just has http://domain.com. what does
this do? of anything. and why would you want to?
  • Borrow -A- Geek
  • Professor
  • Professor
  • User avatar
  • Posts: 763
  • Loc: Dallas/Ft Worth, Texas

Post 3+ Months Ago

actually the more i think about it unflux, i think that that is done server side, with .htaccess files... BIGWeb would you confirm this please?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Well that code you have above is JavaScript. That will not work in .htaccess files. All a .htaccess file allows you to do is use directives to change Apache's configuration.
  • Borrow -A- Geek
  • Professor
  • Professor
  • User avatar
  • Posts: 763
  • Loc: Dallas/Ft Worth, Texas

Post 3+ Months Ago

i know but, i was referring to the more realistic way that the big sites autofix their domain name in the address bar... and i was simply saying it was entirely different through .thaccess file... is this possible?
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Oh I see, um yes it could be. You can perform URL rewriting using mod_rewrite in the .htaccess file. I believe you can go by case too, so it should work.
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

i see...ok thx. :D

no real advantage/disadvantage to using just http://domain.com
rather than http://www.domain.com then??
  • Steen
  • Proficient
  • Proficient
  • User avatar
  • Posts: 343

Post 3+ Months Ago

other then if you want to ensure all your outlinks are coming from the same domain.

we've all seen other peoples in hits from our sites,
where, depending on how the visitor got to your site,
you might find your trading partners with,

http://WWW.GOOGLE.COM=1
http://www.GOOGLE.com=7
http://www.Google.Com=2
GooGLE.COM=1

google.com=8237
http://www.google.com=135693


this is something that could be used to set the referring
page to what you sepcify and thus outhits to other pages
or sites would keep the reffering page name consistant.

you're basicly stearing visitors to the correct URL so you look good!
thats about all I could think something like this would be used for ...


also, you could then check that the referring page is of a value that you will only allow onto the next page.

but yeah, this code snipplet belongs in the letterman's top 10 stupid pet tricks.

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: ScottG and 108 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.