Printer Friendly Version
Email this thread to a friend
|
Featured Web Site Template |
|
Reflects user activity within the last 5 minutes
|
|
| Member |
Message |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-06 21:07
Alrighty.
Recently stepped up to a virtual dedicated server for a site I'm working on.
This was done to be able to ensure proper configurations for SEO needs (redirects on non-www domain, etc.)
Trouble is, I'm not a webmaster, per se, and I'm not a SysAdmin at all.
I'm outta my league here now. The new server is Linux powered, so we'll call that an improvement.
Trouble is, the entire site (all 140 or so pages), was built as asp. Great for making includes for ad sections, navigation, etc.
How the heck do I do this in a Linux environment?
Basically, I need to learn how to set up the pages to have includes for the header, footer, nav & ad section.
I am resigned to rebuilding all the pages. (I'm using Dreamweaver, FWIW)
So, Id' appreciate any help to learn how to get this done as painlessly as possible. The site's still up right now, but I want it switched asap.
Thanks
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2005-Nov-06 21:26
Leave the site at the old server until the new site is built on the new server.
Only when you are happy with the new site switch the DNS over.
On the new server you need the .htaccess file to have the 301 redirect in place: three or four lines of code.
If the page names end in .asp or .html and you are NOT going to change them to be .php (and I would NOT change them right now) then you need to add a handler to the .htaccess file to tell the server to parse them as PHP: one line of code.
Finally you need to edit all the actual pages to use the PHP "include" syntax instead of the ASP code, and then upload them all back to the server.
Don't cahnge any of the names of pages that appear in public, but you might want to put all your include snippets in a separate folder out of the way.
At the same time, edit the pages to make the code cleaner, check for errors, and make sure that each page has a unique page title and description.
Don't switch the new server to "live" until the new site is completely finished. Run the old site on the old server while you work on the new version - even if that is for several months.
|
 |
lizardz
Joined: Nov 12, 2004
# Posts: 1394
|
Posted: 2005-Nov-07 02:55
#Disable .htaccess viewing from browser
<Files ~ "^.htaccess">
Order allow,deny
Deny from all
Satisfy All
</Files>
AddType application/x-httpd-php .htm .html .asp .aspx
DirectoryIndex index.htm index.html index.php default.asp default.aspx
ErrorDocument 404 /site/missing.html
php_value include_path ".:/usr/your/directory/your/includes"
IndexIgnore *
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R=301]
will be your .htaccess file, more or less.
To find the path to server root create a file called test.php
it contains this:
<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>
upload it to the new server, run it, that will show you the path to your document root.
This will be your include path, assuming you have the include folder in your site root folder, which I don't do usually for security reasons, but it doesn't matter for now, plus you can move it later without having to change anything.
then just search and replace the asp include code and change it to php include code.
You can actually not even change the <% to <? if you want, there's an .htaccess way to do that too, but why bother, let's just change it all:
search and replace <% include('leftnav.htm') %>
for
<?php include('leftnav.htm') ?>
that's assuming your left nav include is called leftnav.htm, and that you are just putting it in the first level of your include folder. That's about it.
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-07 12:48
Yeah. Sure thing.
Did I mention I'm not a programmer? LOL
I'm game to learn all this, but everything you two posted is over my head right now. I'm sure it's spot on info, and I'm sure I WILL learn, but oh man, what the ehck have I gotten myself into...
So, in the end, will my pages change from being .asp to .php (or something else other than .asp?)
[ Message was edited by: SportsGuy 11/07/2005 05:14 am ]
[ Message was edited by: SportsGuy 11/07/2005 05:35 am ]
|
 |
waYss
Joined: Mar 13, 2002
# Posts: 209
|
Posted: 2005-Nov-07 14:18
there is a free program called asp2php which can convert a lot of code for you.
Of course its not perfect but saves a lot of hassle.
I just convered 7 websites from asp to php
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-07 15:20
OK, I got the test.php file in there - I guess it had to be put into the cgi-bin folder...wouldn't go anywhere else.
upload it to the new server, run it, that will show you the path to your document root.
Step one done, I think.
Now, how do I run it? Every time I click it, it just opens the doc to show me the code inside (copied & pasted what you provided above).
I'm beginning to see this whole thing as a large mistake...
***********************************************************
Still no luck running that file.
I can't even get access to the ftp side of things - had it yesterday form home, cannot access it today (from work). I opened up all permissions to myself, etc. Pinged the IP (came back fine).
I'm going to fast-forward to the day when I have the server sorted out for this next question:
Might I be better served just reworking this website so all pages are .php instead of .asp? I realize it's a lot of work resaving them all, but I'm going to have to go into each one anyway to update the includes to follow the .php include protocol anyway.
FWIW - Linux server, though I thought I saw in Plesk it said I was running Apache.
I hate feeling this lost...
[ Message was edited by: SportsGuy 11/07/2005 09:28 am ]
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-07 20:01
If the page names end in .asp or .html and you are NOT going to change them to be .php (and I would NOT change them right now) then you need to add a handler to the .htaccess file to tell the server to parse them as PHP: one line of code.
OK, I'm on board with this idea - I actually wanted to just set them all up as basic html pages anyway, so this might work nicely...
Incidentally, where can I find the code to use for this function?
Finally you need to edit all the actual pages to use the PHP "include" syntax instead of the ASP code, and then upload them all back to the server.
I was playing with a page earlier today using <?php include('includes/header.php') ?> as the include command - having trouble setting up the folder "includes", but I think it's a server issue - sent in a trouble ticket.
Don't cahnge any of the names of pages that appear in public, but you might want to put all your include snippets in a separate folder out of the way.
If I follow this bit right, I'd simply drop all my includes into this folder - then when the page is called, php executes it as html, but sticks in my includes. Am I even close to understand it...?
At the same time, edit the pages to make the code cleaner, check for errors, and make sure that each page has a unique page title and description.
Done, done & done - went through it all the first time this puppy went live - won't hurt, though, to double check & clean the code this time around. T's & D's were priority one for me last time.
Don't switch the new server to "live" until the new site is completely finished. Run the old site on the old server while you work on the new version - even if that is for several months.
Amen to that! It's already live on the shared platform, so no rush at this point - if this takes me another month or two I'm fine with that - better right & ready than fast & broken...
Thanks g1 - I truly appreciate your help.
You, too lizard. I haven't created one yet, but that code above will form the basis for my .htaccess file in the near future - heck, I'm going to have questions, too, no doubt.
|
 |
lizardz
Joined: Nov 12, 2004
# Posts: 1394
|
Posted: 2005-Nov-07 20:03
The reason I like using tools like apache, php, etc, are that these tools teach me how the internet works. Every single thing I learn with these tools translates to a more in-depth understanding of the web, and gives me greater and greater control over my sites.
This is a learning curve. You've probably heard that term. Like any powerful tools, you have to learn how to use them. Sounds like you're confused by the basics though.
The time spent learning this stuff is time well spent. The web was built on unix, not on windows. Every part of the web uses unix syntax, not windows syntax. Things that may be mysteries to you currently, like why do website file names use / instead of \ will become clear when you learn how the unix file system and unix file paths actually work.
They are much more logical than the MS version by the way. But they are different.
A linux server is running apache. You need to locate your web root in the filesystem. The directory name is different on different servers so I can't tell you where it is.
That's the folder where when you upload say an index.html file and go to the ip address you will see that file.
That's where the .htaccess file goes. And it's where the website goes.
If you've found it, and if this file content:
<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>
saved as test.php does not display the path to the document root then there is something wrong.
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-07 20:12
Thanks again lizard.
Yeah, right now I'm just frustrated by the "newness" of this stuff to me.
I did create that test.php doc earlier today, but was having a problem getting it to save to the root. I'm pretty sure it's something on the SysAdmin side I have done wrong, but I'll get it sorted...eventually...
|
 |
lizardz
Joined: Nov 12, 2004
# Posts: 1394
|
Posted: 2005-Nov-07 20:31
When you create the ftp account on your ftp client, it will open on the default area of your site. Usually you will see a folder that contains the actual site, can be called different things, sometimes www, sometimes other things.
Not sure what you mean by 'save to root'.
You create the document, you save it, you upload it to the website root directory. Use a real ftp client,don't use dreamweaver.
Filezilla is good.
Once the test.php is loaded, you just type in your ip address + /test.php in your browser and it will execute.
It has no choice but to execute. If it doesn't show the information, and just the actual code, there's a problem.
Your include path is wrong, you have to set that in .htaccess BEFORE you add that path to the html page.
This path is absolute, to the server root, or in some case with virtual servers, to your local server root. It's hard to know which it is with shared servers, the quickest way to find it is to run the test.php script, that prints it out.
Once you set the path in .htaccess, you do not need to then again set the path in the <?php include...?> statement, it's already set.
Setting the path in .htaccess creates a virtual path, all you need to put in the include statement is the path from inside the includes folder.
say:
/usr/local/yourusername/includes/leftnav.htm
would be <?php include('leftnav.php'); ?>
/usr/local/yourusername/includes/html/leftnav.htm
would be <?php include ('html/leftnav.htm'); ?>
Notice here that you can put the includes directory anywhere you want on the web server that you have access privileges to.
Say your site is in www directory:
includes are in:
/usr/local/yourusername/includes
website is in
/usr/local/yourusername/www
the main thing that is going to trip you up with apache/php/linux is that it is really logical. Windows is fundamentally illogical, that's because they keep trying to make it so 'user friendly' that your grandmother can use it. That means it must be illogical, since most people are illogical, especially our mothers and grandmothers.
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-07 20:46
There inlies the rub - I just transfered that test.php file I created earlier today with your info to the server.
Dropped it right onto the root. Not inside any other folders, etc.
What does filezilla tell me - critical transfer error - what does Firefox show me - 404 Not Found. I have not been able to create directories on this server, nor can I, it seems, upload files to where I choose. I have a trouble ticket in, but it'll be tomorrow before I hear anything.
*Frustrating*
Slowly but surely the pieces are falling into place, but man, this is maddening.
Crap, I took my first salsa lesson last Friday night - THAT was much more fun... And easier to learn, too. Perhaps I should just become a dancer...
|
 |
lizardz
Joined: Nov 12, 2004
# Posts: 1394
|
Posted: 2005-Nov-07 21:10
This all depends on the hoster, some allow more control than others.
It's highly variable. That's why I only use a tiny handful of hosters, those are the ones that let me do everything I want, however I want.
Took me a long time to figure out why that was important.
Odds are good you're doing something wrong, or trying to make a folder in an area that doesn't allow that.
Hard to say without seeing the layout myself.
If you're on media temple, they use virtualized servers.
the path to your main account directory is:
/var/www
that's what filezilla opens on.
your website is in /var/www/html
this is where all site files go, including the test.php you will run
If you're on media temple, you are currently trying to write to a protected area, you can only write to the interior directories in that area. That' why you are getting error reports.
you can put your includes folder in /var/www/data
you can't write to the main folders on that level.
If this is what you see, your include path is:
/var/www/data/includes
Once I started using quality hosters it took me a while to realize that in almost all cases the mistake is mine, not theirs, though tech support tends to be pretty patient with user errors.
Now I make absolutely certain I'm not making the mistake, or as certain as I can be, before asking for tech support. And even then it's still almost always something I've done wrong.
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2005-Nov-07 23:20
Heh, if you want to think about this in a way that is related to Windows for a moment...
When you want to store a document on your hard drive you could simply click on the "C:" drive and then store it.
But, you have just put it in the root.
Wouldn't it be more useful to put in in "C:/Documents/User.Name/My.Documents/"?
Yes it would!
And hence, back to your website...
When you FTP into your server, the "root" folder is not the one that the public website goes in.
It goes in a folder, often called html_public or www and then it will be visible to the outside world.
Other folders that are "above the web root" will hold your site log files (see that folder called logs?), and maybe any database files (if you later have a dynamic site), and other things like passwords for users (so that people cannot browse those directories -- much like if you share your Windows documents folder with someone over a network, that they cannot look in your Program.Files folder because it is above the My.Documents "Root").
This will all get easier very quickly.
|
 |
lizardz
Joined: Nov 12, 2004
# Posts: 1394
|
Posted: 2005-Nov-07 23:38
Just to add a pointless observation:
Once I was going to do a networking job, windows system. On the way, I read a Linux book, to brush up on stuff, and because my laptop battery was not working, had to do something constructive on the flight.
I happened to read about linux mounting and unmounting of drives, and related concepts.
During the job, I found the solution by realizing that a certain dumbly named windows operation in fact was simply mounting and unmounting a drive, which let me figure out a fairly slick solution to that particular problem.
What happens in unix/linux is direct, what happens in windows is the same, technically, especially with web and directory construction, but windows hides the procedures, gives them new cute names, and so on.
This does not help you learn. With Windows, you will not learn what is happening until you study the core systems, and what they do. That's much harder to see in windows than linux/unix, and it's why people who know tend to really hate windows.
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-10 00:44
If you've found it, and if this file content:
<?php
echo $_SERVER['DOCUMENT_ROOT'];
?>
saved as test.php does not display the path to the document root then there is something wrong.
Well, I got it sorted this evening - thanks again for this tip Lizard.
*smacks hands together* Things are going to get dangerous now!
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2005-Nov-10 01:13
Uh Oh...
As for the "one line of code" that you asked me about, lidardz posted it just above (before) where you asked the question.
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-10 13:03
Thanks g1. Looks liek I'm going to step back form the server side of things for a bit now, and concentrate on the site redesign.
After continuing to research & build some knowledge, it looks like I'm going to rebuild the site as .php completely. I could get the pages to show as .asp, but if the asp functionality isn't going to work, I don't really see the point.
Might as well start in the top left hand corner and rework everything I've been wanting to.
Thanks fully the nav is in an include, so an hour or so and all those links are rewritten. I've been planning on more internal cross-links anyway, so now's the time to include those, too.
Going to centre the pages on the screen, maybe set the background one shade darker that whie to offer a small amount of contrast, got to rework some of my templates to use % instead of pixel to define table widths, too - I HATE seeing some pages suddenly 20 pixels wider than others...
Ah, the ever evolving web...I think I love it again...LOL
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2005-Nov-10 13:26
The actual filenames of your site are unimportant, but if you have pages already indexed then I would not change the names at all.
This line of code in the .htaccess file allows you to leave the names as they are and let the server still work on any PHP code found within the pages:
AddType application/x-httpd-php .htm .html .asp .aspx
I can really recommend using that.
|
 |
SportsGuy
Staff
Joined: Aug 30, 2002
# Posts: 3600
|
Posted: 2005-Nov-10 13:36
My plan is to make this type of change:
domain.com/folder/filename.asp
Changes to:
domain.com/folder/filename.php
Folders and filenames to remain as before - just the extensions to change. I do have a bunch of pages form this site indexed, so I'm keen to leave the content in the same locations.
See any obvious issues with this plan?
|
 |
g1smd
Staff
Joined: Jul 28, 2002
# Posts: 10438
|
Posted: 2005-Nov-10 13:57
The main thing is that unless you add a 301 redirect fom the old URL to the new URL you will lose all the backlinks to your site, their traffic, and their PR.
You also risk Google flagging the site as being new and dropping it in the sandbox for a year.
There really is no problem at all to have the page name end in .asp but to actually contain PHP scripts. It is just a name. The file names could end in .golf and it really would not matter at all.
Change the internal workings of the page to use PHP on the server. The pages will still output plain HTML code as they have always done. Leave the filename alone. Leave it as .asp; it isn't worth the risk to change the name.
|
 |
You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
- You have not yet logged in, or registered properly as a member
- You are a member, but no longer have posting rights.
- This is a private forum, for which you do not have permissions.
If you are a recent member, it's possible that you simply have not yet confirmed your account. Please
check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions
contained within.
If you cannot find this message, click here to Re-Send it.
|
If you are still experiencing problem, please read the
Login Assistance
Article for some advice on what may be causing your login not to work properly.
|
Switch to Advanced Editor and ...
Create a New Topic
or Reply to this Thread
|
|