Tools Links Login

Extended Urls / Fake Urls

:How to extend your urls dynamically using a Mysql Database without having file structures for every directory in your Url's, this code will improve search engine status of your website and much more.

Original Author: Mr.Miagi

Code


404.asp


thisstyle='font-size:14.0pt'> page should be put as your custom error page for 404
http errors.


style='background:#B3B3B3;border-collapse:collapse;border:none;mso-border-alt:
solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext'>




<%option
explicit%>


<%


dim
refer, indexc, strpage,strpagename,
dbcon, connection, sql, class=SpellE>dbrs
, realpage


refer= class=SpellE>Request.ServerVariables("QUERY_STRING")


indexc=instrrev(refer,"/")


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+
getting the number of "/" in refer


'+ and
stripping them off


'+
then removing the .htm or .html from them


'++++++++++++++++++++++++++++++++++++++++++++++++++


if ( class=SpellE>indexc>0) then


strpage = Right(refer,Len(refer)- class=SpellE>indexc)


refer
= Left(refer,indexc-1)


end if


strpage=replace(strpage,".html","")


strpage=replace(strpage,".htm","")


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ class=GramE>connection strings...


'+ class=SpellE>sql= all fields where the page name is the requested class=SpellE>url


'+
that we stripped above


'++++++++++++++++++++++++++++++++++++++++++++++++++


set class=SpellE>dbcon = server.createobject(" class=SpellE>adodb.connection")


connection
= "Driver={Mysql}; Server=69.56.199.234;
Database=; UID=; PWD=;"


SQL =
"SELECT * FROM `pages` WHERE PageName='"& class=SpellE>strpage
&"'"


dbcon.open(connection)


set class=SpellE>dbrs = server.CreateObject(" class=SpellE>adodb.recordset")


dbrs.open sql, dbcon


if not
dbrs.eof then


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+
setting our variables


'+
setting the session of the pageID since we cannot


'+
transfer regular variables in server.transfer


'++++++++++++++++++++++++++++++++++++++++++++++++++


set class=SpellE>realpage=dbrs.fields(" class=SpellE>realpage")


session(" class=SpellE>PageID")=dbrs.fields(" class=SpellE>PageID")


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+
Sending the user a page, but not redirecting them


'+ ( class=SpellE>realpage) should be a field in our database with the page
name. EX. "News"


'+
then we redirect them to our main page if it is a REAL 404 error


'++++++++++++++++++++++++++++++++++++++++++++++++++


server.transfer("/asp/"&realpage&".asp")


else


response.redirect("index.html")


dbrs.close


dbcon.close


end if


%>



 


Wwwroot/asp/urlgen.aspstyle='font-size:20.0pt'>


thisstyle='font-size:14.0pt'> page contains the script which generates the fake class=SpellE>urls


style='background:#333333;border-collapse:collapse;border:none;mso-border-alt:
solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext'>




<%


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ this page writes our very false urls
and puts


'+ them into links


'++++++++++++++++++++++++++++++++++++++++++++++++++


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ this is our domain, change it to your domain


'+ domain format must include http://'YOUR DOMAIN'/


'++++++++++++++++++++++++++++++++++++++++++++++++++


const url="http://halonation.com/"


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ our function for creating urls


'+ writes a link with the db urls,
page directories


'+ and pagename+ a . class=SpellE>htm


'++++++++++++++++++++++++++++++++++++++++++++++++++


Function CreateUrl(ID)


set dbcon = server.createobject(" class=SpellE>adodb.connection")


connection = "Driver={Mysql};
Server=69.56.199.234; Database=; UID=; PWD=;"


SQL = "SELECT * FROM `pages` WHERE PageID='"&ID&"'"


dbcon.open style='font-size:11.0pt;font-family:Garamond;color:white'>(connection)


set dbrs = server.CreateObject(" class=SpellE>adodb.recordset")


dbrs.open style='font-size:11.0pt;font-family:Garamond;color:white'> class=SpellE>sql, dbcon


if not dbrs.eof then


pagename style='font-size:11.0pt;font-family:Garamond;color:white'>= class=SpellE>dbrs.fields("pagename")


pagedir style='font-size:11.0pt;font-family:Garamond;color:white'>= class=SpellE>dbrs.fields("pagedir")


CreateUrl style='font-size:11.0pt;font-family:Garamond;color:white'>=url&pagedir&pagename&".htm"


end if


dbrs.close style='font-size:11.0pt;font-family:Garamond;color:white'>


dbcon.close style='font-size:11.0pt;font-family:Garamond;color:white'>


End Function


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ our function for making the link name


'+ connects, gets linkname from the
DB, and returns it


'++++++++++++++++++++++++++++++++++++++++++++++++++


Function CreateName(ID)


set dbcon = server.createobject(" class=SpellE>adodb.connection")


connection = "Driver={Mysql};
Server=69.56.199.234; Database=; UID=; PWD=;"


SQL = "SELECT `linktext` FROM
`pages` WHERE PageID='"&ID&"'"


dbcon.open style='font-size:11.0pt;font-family:Garamond;color:white'>(connection)


set dbrs = server.CreateObject(" class=SpellE>adodb.recordset")


dbrs.open style='font-size:11.0pt;font-family:Garamond;color:white'> class=SpellE>sql, dbcon


if not dbrs.eof then


CreateName style='font-size:11.0pt;font-family:Garamond;color:white'>= class=SpellE>dbrs.fields("linktext")


end if


dbrs.close style='font-size:11.0pt;font-family:Garamond;color:white'>


dbcon.close style='font-size:11.0pt;font-family:Garamond;color:white'>


End Function


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ connection strings


'+ rowcount gets the number of rows
total, for our Loop


'++++++++++++++++++++++++++++++++++++++++++++++++++


set dbcon = server.createobject(" class=SpellE>adodb.connection")


connection = "Driver={Mysql};
Server=69.56.199.234; Database=; UID=; PWD=;"


SQL = "SELECT COUNT(*) as Count FROM `pages`"


dbcon.open style='font-size:11.0pt;font-family:Garamond;color:white'>(connection)


set dbrs = server.CreateObject(" class=SpellE>adodb.recordset")


dbrs.open style='font-size:11.0pt;font-family:Garamond;color:white'> class=SpellE>sql, dbcon


RowCount style='font-size:11.0pt;font-family:Garamond;color:white'>= class=SpellE>dbrs("Count")


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ we loop Loopvar1 to Rowcount to
write every link


'+ inside the DB, you might want to change this


'+ depending on which page it is displayed on.,


'+ just remove rowcount= class=SpellE>dbrs("count") and replace with


'+ RowCount='YOUR COUNT


'++++++++++++++++++++++++++++++++++++++++++++++++++


for LoopVar1=0 to RowCount%>


<a href=<%=CreateUrl(LoopVar1)%>><%= class=SpellE>CreateName(LoopVar1)%></a>


<br>


<%next


'++++++++++++++++++++++++++++++++++++++++++++++++++


'+ disposing of garbage..


'+


'++++++++++++++++++++++++++++++++++++++++++++++++++


set dbrs=nothing


set dbcon=nothing%> style='font-size:11.0pt;font-family:Garamond'>



 


 


 


Use This SQL To create your table
correctly.


style='background:#0C0C0C;border-collapse:collapse;border:none;mso-border-alt:
solid windowtext .5pt;mso-yfti-tbllook:480;mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-border-insideh:.5pt solid windowtext;mso-border-insidev:.5pt solid windowtext'>




CREATE TABLE `pages` (


 
`PageID` tinyint(4)
NOT NULL auto_increment,


 
`PageName` tinytext,


 
`PageDir` text,


 
`RealPage` tinytext,


 
`LinkText` tinytext,


 
PRIMARY KEY  (` class=SpellE>PageID
`)


) TYPE=MyISAM;



 


To Conclude, write a <!--#include virtual=”./asp/class=SpellE>urlgen.asp”--> in the body of your content page inside
root/asp/ where you want your links generated. And always- CUSTOMIZE


Summary:

Extended Urls help with marketing, page rank on
search engines, and much more. Without having to really make all the
directories physically. I have a running example of this code at href="http://www.halonation.com/asp/news.asp">www.halonation.com/asp/news.asp,
or any url you can think of that isn't on my web
server- J

On A side note, if anyone finds out a way to include char(63), &#63;, or ? class=GramE>into the server.transfer without
getting a server.mappath error, please tell me,
because that is one of the things that would make this script Very Good.


 


This Code has been provided free grant of use
non-commercially


Copywritestyle='font-family:Garamond'> synapse design 2003-2004


About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 91 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.