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 <%option <% dim refer= class=SpellE>Request.ServerVariables("QUERY_STRING") indexc=instrrev(refer,"/") '++++++++++++++++++++++++++++++++++++++++++++++++++ '+ '+ and '+ '++++++++++++++++++++++++++++++++++++++++++++++++++ if ( class=SpellE>indexc>0) then strpage = Right(refer,Len(refer)- class=SpellE>indexc) refer 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 '+ '++++++++++++++++++++++++++++++++++++++++++++++++++ set class=SpellE>dbcon = server.createobject(" class=SpellE>adodb.connection") connection SQL = dbcon.open(connection) set class=SpellE>dbrs = server.CreateObject(" class=SpellE>adodb.recordset") dbrs.open sql, dbcon if not '++++++++++++++++++++++++++++++++++++++++++++++++++ '+ '+ '+ '++++++++++++++++++++++++++++++++++++++++++++++++++ set class=SpellE>realpage=dbrs.fields(" class=SpellE>realpage") session(" class=SpellE>PageID")=dbrs.fields(" class=SpellE>PageID") '++++++++++++++++++++++++++++++++++++++++++++++++++ '+ '+ ( class=SpellE>realpage) should be a field in our database with the page '+ '++++++++++++++++++++++++++++++++++++++++++++++++++ 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 <% '++++++++++++++++++++++++++++++++++++++++++++++++++ '+ this page writes our very false urls '+ 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, '+ and pagename+ a . class=SpellE>htm '++++++++++++++++++++++++++++++++++++++++++++++++++ Function CreateUrl(ID) set dbcon = server.createobject(" class=SpellE>adodb.connection") connection = "Driver={Mysql}; 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 '++++++++++++++++++++++++++++++++++++++++++++++++++ Function CreateName(ID) set dbcon = server.createobject(" class=SpellE>adodb.connection") connection = "Driver={Mysql}; SQL = "SELECT `linktext` FROM 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 '++++++++++++++++++++++++++++++++++++++++++++++++++ set dbcon = server.createobject(" class=SpellE>adodb.connection") connection = "Driver={Mysql}; 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 '+ 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 CREATE TABLE `pages` ( ) TYPE=MyISAM; To Conclude, write a <!--#include virtual=”./asp/class=SpellE>urlgen.asp”--> in the body of your content page inside Summary: This Code has been provided free grant of use Copywritestyle='font-family:Garamond'> synapse design 2003-2004
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'>
explicit%>
refer, indexc, strpage,strpagename,
dbcon, connection, sql, class=SpellE>dbrs, realpage
getting the number of "/" in refer
stripping them off
then removing the .htm or .html from them
= Left(refer,indexc-1)
that we stripped above
= "Driver={Mysql}; Server=69.56.199.234;
Database=; UID=; PWD=;"
"SELECT * FROM `pages` WHERE PageName='"& class=SpellE>strpage&"'"
dbrs.eof then
setting our variables
setting the session of the pageID since we cannot
transfer regular variables in server.transfer
Sending the user a page, but not redirecting them
name. EX. "News"
then we redirect them to our main page if it is a REAL 404 error
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'>
and puts
page directories
Server=69.56.199.234; Database=; UID=; PWD=;"
DB, and returns it
Server=69.56.199.234; Database=; UID=; PWD=;"
`pages` WHERE PageID='"&ID&"'"
total, for our Loop
Server=69.56.199.234; Database=; UID=; PWD=;"
write every link
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'>
`PageID` tinyint(4)
NOT NULL auto_increment,
`PageName` tinytext,
`PageDir` text,
`RealPage` tinytext,
`LinkText` tinytext,
PRIMARY KEY (` class=SpellE>PageID`)
root/asp/ where you want your links generated. And always- CUSTOMIZE
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), ?, 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.
non-commercially
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.