PDA

View Full Version : Possible problem with URL rewrite or base URL


absolethe
May 31st, 2007, 20:57
I frequently see in my stats URLs that appear "stacked." Not a lot, but 1 or 2 every month, like:

www.virtualrevolution.net/Resume/Resume/
www.virtualrevolution.net/Contact/Contact/
www.virtualrevolution.net/Portfolio/Contact/

I use <base href="http://www.virtualrevolution.net/" /> and usually link to pages like <a href="Contact/">.

Cuz something about what I've done doesn't work without it. Or, maybe it just doesn't work when I'm working on my site locally (WAMP). Whatever, I've used it for a while and I've forgotten the specifics.

I use some probably crappy, but working mod_rewrite. I've never had one of my links stack up like that when clicking around, but I'm not entirely sanguine that these are being entered by hand.

My relevant re-write rules are:

RewriteCond %{REQUEST_URI} ^/stats/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/statistics/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.*$ - [L]
RewriteCond %{REQUEST_URI} ^/showimage/(.*)$
RewriteRule ^showimage/(.+[^/])/?$ /code_showimage.php?i=$1 [NC,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+[^/])$ /index.php?p=$1 [NC,QSA,L]
RewriteRule ^(.+)/$ /index.php?p=$1 [NC,QSA,L]

And if there's a way to make that more elegant, I'd sure love to hear it. I read and I read and I think I understand, but I sweat blood to get it to work the way I think it should. :D

Does anyone know of any reason why the links would "stack" that way on their own?

BigBison
June 1st, 2007, 04:21
Let's back up a bit. Are you just trying to make /Portfolio.php linkable as /Portfolio? Then yes, there's an easier way, in your .htaccess make a line:

Options MultiViews

That might make it easier to deal with disallowing hotlinks, if that's what you're doing, as your rewrite rules would be considerably smaller. It would probably fix the issue you're having too.

absolethe
June 3rd, 2007, 02:58
Sort of...

It's:
http://www.virtualrevolution.net/index.php?p=Portfolio
to
http://www.virtualrevolution.net/Portfolio

And:
http://www.virtualrevolution.net/code_showimage.php?i=whatever.jpg
to
http://www.virtualrevolution.net/showimage/whatever.jpg

It's just for "easier to remember" URLs without query strings. I have separate rules to disallow hotlinking (referrer checks).

And, honestly, I've never seen http://www.virtualrevolution.net/Portfolio/Portfolio happen personally. And I navigate my own site frequently. I just see it in my logs sometimes and I am starting to wonder if my first thought, "someone's typing it in wrong" could have been mistaken.

inimino
June 3rd, 2007, 09:33
Your rewrite rules look fine to me. (However, what would happen if you deleted the first four lines?) What is the Referer on those 404s?

absolethe
June 4th, 2007, 16:58
The /stats/ directory is how I get to the pre-installed analog stats thingie. But it's some kind of ... it's not a physical directory, because I don't actually have a stats folder in my web root. I get a 404 when trying to get to analog if those lines aren't there...I think.

I added the other one when I installed awstats, but it actually doesn't do anything. I was trying to make it not give me an error if all I typed was www.virtualrevolution.net/statistics/ as opposed to statistics/awstats.virtualrevolution.net.html. Which didn't help, but I just left it there. :)

I looked over the last few days, and all the examples of incorrect paths are actually bots: MSN and Google specifically. I don't know if that's always the case, because I don't always look at my actual logs to associate the URL with a particular visiter or referrer.

66.249.66.164 - - [03/Jun/2007:12:34:13 -0700] "GET /Portfolio/Portfolio HTTP/1.1" 200 6843 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"
65.55.213.75 - - [03/Jun/2007:04:09:32 -0700] "GET /Index/xml/vr_atom.xml HTTP/1.0" 200 3668 "-" "msnbot-media/1.0 (+http://search.msn.com/msnbot.htm)"

And now I'm annoyed at that 200. I'm trying to make sure my custom error page returns a 404 everytime. Just because the server returns a 200 there doesn't mean that Googlebot isn't getting my 404, right? I've got a thing in php that says:


elseif($realpage[0] == 0){
$page = $realpage[1];
header("Status: 404 Not Found");
}


But I'm never sure it's working as I'd like. All I know is that there's no "headers already sent" error.

And I wonder where the bots are getting those URLs...

The Portfolio/Portfolio is still mysterious to me, but the XML one looks like it's just be me being dumb--


<link rel="alternate" type="application/atom+xml" title="Virtual Revolution News Feed (Atom)" href="xml/vr_atom.xml" />
<link rel="alternate" type="text/xml" title="Virtual Revolution News Feed (RSS 2.0)" href="xml/vr_rss2.xml" />
<base href="http://www.virtualrevolution.net/" />


*cough* Well, I can fix that...

BigBison
June 5th, 2007, 00:41
And now I'm annoyed at that 200. I'm trying to make sure my custom error page returns a 404 everytime. Just because the server returns a 200 there doesn't mean that Googlebot isn't getting my 404, right?

Congratulations, you are one of very few PHP developers who ever seem to notice that! You are correct, bots look at the response code, they don't assume that the text "404 Not Found" in the message body means anything, nor should they. This is indeed what HTTP status codes are for. You get a smilie:

:)

inimino
June 5th, 2007, 00:46
And now I'm annoyed at that 200. I'm trying to make sure my custom error page returns a 404 everytime. Just because the server returns a 200 there doesn't mean that Googlebot isn't getting my 404, right?

Google sees what your server sends which is what your server logs.

http://www.google.com/search?q=site:virtualrevolution.net+%22cannot+be+f ound%22l&filter=0

I've got a thing in php that says:


elseif($realpage[0] == 0){
$page = $realpage[1];
header("Status: 404 Not Found");
}


My experience with PHP is that it always sends 200. This may have changed or you may need closer integration with Apache if you care about serving correct status codes. You might look into using RewriteMap.

And I wonder where the bots are getting those URLs...

The Portfolio/Portfolio is still mysterious to me

From that same page:
<a href="Portfolio/" ...
What happens to the spider when it hits this link and it's already on Portfolio/ ? Bots sometimes don't handle <base>, which isn't doing you any good anyway... I would lose the <base> and simply write the URL you mean directly:

<a href="/Portfolio/"

absolethe
June 12th, 2007, 18:07
Thanks for the tip. I will look at RewriteMap.

All the sites I've read seem to think that sending a 404 status like that, using header() is sufficient, but apparently they lie. ;)

I took your advice and removed the <base> url. Because I'm re-writing to fake directories like that (rather than, say, portfolio.html), I found it convenient.

inimino
June 12th, 2007, 22:07
Incidentally, as a matter of style, I would use directory paths (ending in slash, e.g. "/Portfolio/") only for resources that are logical directories: pointers to other resources. "Portfolio/" implies a directory and makes perfect sense, "Resume/" does not make sense because it is logically a file, that is, a leaf node on the filesystem tree. (Of course, "Portfolio/" would make even more sense if you had "Portfolio/entry" for every entry in your portfolio, rather than that ugly showimage URI, and you can fix that using rewrite rules as well.)

Using RewriteMap you can specify the precise URIs you need and Apache will handle errors appropriately for you in any other case.

absolethe
June 15th, 2007, 00:14
I've had some trouble figuring out how to get 301 redirects--probably for the same reason those 404's weren't working correctly.

I've tried an htaccess Redirect 301, but that didn't work at all...

So after I did this stuff, it occurred to me I might want to use something other than /showimage/. But I was afraid to change it. Not that I really have any search engine ranking, mind you. But I figured I'd eventually figure out the 301 and then I'd do it.

"Although you can use a rewrite map anywhere (i.e., including .htaccess files), you can only define them in your main Apache configuration file. This has to do with the fact that the map is loaded on server startup, and so putting it in a .htaccess file wouldn't really work."

I don't think I have access to the configuration file under my shared hosting plan...

inimino
June 15th, 2007, 03:01
Hm, redirects from .htaccess should work. What did you try?

absolethe
June 20th, 2007, 00:26
When I tried (originally, once or twice a few months back) I first tried a simple Redirect in a couple of situations (Redirect 301 /old http://www.domain.com/new). I also played around with RedirectMatch and a redirecting in my rewrite rules using R=301.

I'm still not entirely sure about the simple "Redirect", but it seems likely that I was probably just making repeated mistakes in my expressions with the other two--

Cuz I got (I'm pretty sure) showimage/whatever.jpg 301 redirecting to portfolio/whatever.jpg. It redirects, anyway. Using something along the lines of:
RewriteCond %{REQUEST_URI} ^/showimage/(.*)$
RewriteRule ^showimage/(.+[^/])/?$ /Portfolio/$1 [R=301,NC,L]
(don't have it in front of me right now).

I was wondering if this would make any improvement on how my script is currently NOT sending status headers (at least not the way/or when I want it to), even though I thought I was giving correct instructions... I saw this today:

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/newpage/newurl.htm");
exit();

I haven't yet ever used exit(). (I'm probably a terribly messy programmer.) But maybe if I use it, the headers won't get 'changed' from 301 or 404 to 200? Is that actually what's happening, I wonder?

If I'm sending the headers first thing first every single time the Error page is displayed (via whatever logic the Error page was chosen, there are a few), why ISN'T the status actually 404?

- And one of the crappy things about changing my links is that it makes it more difficult to test on my own computer. Physically the site is located at C:\Server\Sites\vr-3-12-3-dl. Localhost is C:\Server\Sites. When I link to /Resume/, instead of using <base> and Resume/ well, obviously I get a 404. Bleh.

absolethe
June 20th, 2007, 00:55
PS: I'm just going to have to set up Virtual Hosts again. ;) I've done it before, but I didn't find it convenient enough to continue with. To do...

inimino
June 20th, 2007, 01:47
I was wondering if this would make any improvement on how my script is currently NOT sending status headers (at least not the way/or when I want it to), even though I thought I was giving correct instructions... I saw this today:

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.newdomain.com/newpage/newurl.htm");
exit();

exit() isn't necessary, it will exit anyway when it gets to the end of the file. There's no reason you can't set the status code but also serve an entire HTML document explaining the situation.

By the way, that's a status code, not a header. The server sends it on the first line, before any of the headers, which come on the subsequent lines.

If I'm sending the headers first thing first every single time the Error page is displayed (via whatever logic the Error page was chosen, there are a few), why ISN'T the status actually 404?

The problem probably has to do with Apache integration and mod_php. I've tried this again with PHP 5 and Apache 2, and it works now, so whatever problem existed the last time I looked at this seems to have been resolved.

And one of the crappy things about changing my links is that it makes it more difficult to test on my own computer. Physically the site is located at C:\Server\Sites\vr-3-12-3-dl. Localhost is C:\Server\Sites. When I link to /Resume/, instead of using <base> and Resume/ well, obviously I get a 404. Bleh.

Whereas with <base> it would take you off your development pages and to the live site. You can create a subdomain like test.example.com and use that for testing, so both absolute and relative path URIs will still resolve, but stay within your testing environment.

absolethe
June 25th, 2007, 23:55
I think I'm using one of the latest versions of PHP 4 and Apache 1.3.x ish both at home and on my host. PHP is running as a CGI module.

Why are there all these tutorials with this method if there's a long-standing integration problem? That's weird.

I thought that status codes were part of the header information. :) But I'm not surprised to find myself misusing terminology.

I have a variable $basehref that is set to http://www.virtualrevolution.net on my host and http://localhost/vr-3-12-3/ on my local computer. It sits around in a file with the rest of the basic, disparate information.

But I set up virtual hosts over the weekend, so I'm good again. :)

inimino
June 26th, 2007, 03:14
I think I'm using one of the latest versions of PHP 4 and Apache 1.3.x ish both at home and on my host.

Apache 2 and PHP 5 have both been out for about three years now, and Apache 2.0 is already obsoleted by 2.2, so you might consider upgrading.

PHP is running as a CGI module.

You might also try mod_php.

PHP parses the HTTP headers and does creative things with them which, at least in the past, have been notoriously buggy. Probably some combination of the ancient versions and the use of the CGI interface is the source of the problem.

absolethe
June 26th, 2007, 18:50
I'm mostly conforming to what's on my host. I know I have the option to run PHP 5, but I'm fairly certain Apache 1.x is my only option there (though it might not be, I'll look into it).

I've attempted to install those for purposes of playing around, once around 2-3 years ago, and once around a year ago. Of course, both times I had nothing but trouble getting PHP 5 to run with Apache 2, even though the 2nd time I downloaded some special DLLs that were specifically supposed to make it work.

Know of a good installation walkthrough for Windows XP, Apache 2, and PHP 5? I follow directions good. ;)

BigBison
June 26th, 2007, 20:34
BigBison's hint of the month:

Find a host with Apache 2.2 and mod_python and write your apps using Django (http://www.djangoproject.com/documentation/install/). Why use PHP? It only gets in the way. Python's the new BASIC, and Django has a clue about proper HTTP.

inimino
June 26th, 2007, 21:03
Know of a good installation walkthrough for Windows XP, Apache 2, and PHP 5? I follow directions good. ;)

What I would do:

1. Install Debian.
2. Run "apt-get install php5 apache2".
3. There is no step three.

I haven't used Windows since before XP, so I can't really help you there.

BigBison's hint of the month:

Find a host with Apache 2.2 and mod_python and write your apps using Django (http://www.djangoproject.com/documentation/install/). Why use PHP? It only gets in the way. Python's the new BASIC, and Django has a clue about proper HTTP.

Good advice. If you're going to go to the effort of learning a programming language, let it not be PHP.

Pattons3rd
June 26th, 2007, 21:40
BigBison's hint of the month:

Find a host with Apache 2.2 and mod_python and write your apps using Django (http://www.djangoproject.com/documentation/install/). Why use PHP? It only gets in the way. Python's the new BASIC, and Django has a clue about proper HTTP.

So PHP isn't worth learning?
Or do you mean for writing apps?

Where should I learn Python?
And what about PERL?

inimino
June 26th, 2007, 21:48
So PHP isn't worth learning?

There are much better programming languages to learn. If you need to use PHP for something later, you can pick it up in a week if you have learned some other languages first.

Or do you mean for writing apps?

As opposed to what?

Where should I learn Python?

http://www.python.org/

And what about PERL?

You should not learn Perl unless you are a Unix systems administrator.

Pattons3rd
June 26th, 2007, 22:00
There are much better programming languages to learn. If you need to use PHP for something later, you can pick it up in a week if you have learned some other languages first.
I guess thats so.
Python does seem a little hard to begin with though.

As opposed to what?
As opposed to using it as a server-side language for handling forms, databases etc etc.

http://www.python.org/
Ok, I guess I will start with it there.


You should not learn Perl unless you are a Unix systems administrator.
Thank you so much!! You have just saved me tons of trouble!

BigBison
June 27th, 2007, 04:00
As opposed to using it as a server-side language for handling forms, databases etc etc.

If you're writing a desktop app, use Python. If you're writing a Web app, use a Web framework for Python, i.e. Django.

Pattons3rd
June 27th, 2007, 15:40
Okay I will try to learn that ASAP.
So Django is just an editor right?

Is there any browser that won't support Python?

inimino
June 27th, 2007, 21:49
No, Django is a framework. If you want to learn Python, start with some simple examples or tutorials and just learn Python. Then you can learn Django (and HTTP). Django is a collection of Python code written by other people which you can use to make certain tasks easier. It's not an editor.

Python is supported by servers, not browsers. Your server should produce plain HTML, the browser has no way to tell and no reason to care what technology you use to generate that HTML on the server side.

BigBison
June 27th, 2007, 22:37
Whoops! I almost forgot, you'll need to install httplib2:

http://bitworking.org/projects/httplib2/

BigBison
June 28th, 2007, 20:41
Python news:

http://www.artima.com/weblogs/viewpost.jsp?thread=208549

Django news:

http://www.djangoproject.com/weblog/2007/jun/26/djangostatusupdate/

Pattons3rd
June 29th, 2007, 01:36
No, Django is a framework. If you want to learn Python, start with some simple examples or tutorials and just learn Python. Then you can learn Django (and HTTP). Django is a collection of Python code written by other people which you can use to make certain tasks easier. It's not an editor.

Python is supported by servers, not browsers. Your server should produce plain HTML, the browser has no way to tell and no reason to care what technology you use to generate that HTML on the server side.
I guess I meant to say do most servers support it, sorry about that.

Yeah I guess I will just try to use the tutorials and such because our library and the libraries around for miles don't have any Python books.

Whoops! I almost forgot, you'll need to install httplib2:

http://bitworking.org/projects/httplib2/
WHat is this needed for? To view Python?

BigBison
June 29th, 2007, 01:56
I guess I meant to say do most servers support it, sorry about that.

All servers support it, provided that Python is installed on the server, as with any programming language some sort of compiler or interpreter is needed to turn your code into an executable.

Yeah I guess I will just try to use the tutorials and such because our library and the libraries around for miles don't have any Python books.

Or, just register for O'Reilly's "Safari" service so you can read their books online. Like, "Python in a Nutshell" although that's more of a reference than a tutorial.

WHat is this needed for? To view Python?

Like any programming language, all that's needed to view code is a text editor. Of course, there are IDEs out there also, which make it easier to code but I really can't help you with that.

What httplib2 is, is a standard code library, meant to replace httplib -- which is one of the standard code libraries installed with Python. If you need to write some sort of code which uses HTTP to GET another page, or an image, or whatever then you can either write all the code needed to request a remote file over the network from scratch, after thoroughly understanding the RFC 2616 spec...

...or you can use the standard code library included in Python, httplib, which already implements HTTP GET for you. Of course, that doesn't cache the result, so if you need to access the same remote resource using HTTP GET again, you'll wind up with a round-trip over the network. Unless you use httplib2, which understands HTTP caching, in which case if your application needs the same file twice it will just pull it from the local cache instead of going over the network to get it.

Just like how your browser has a cache. So if you want something like your browser's cache involved in your application, be it a client application or a server application, you would write code which calls the functions in the httplib2 library instead of writing code which calls the functions in the httplib library.

inimino
June 29th, 2007, 05:24
I guess I meant to say do most servers support it, sorry about that.

If you are thinking of typical $5/month hosting accounts, some do, but not as many as support PHP. If you need an account to learn on, I can give you a shell account on one of my servers. (That goes for anyone here on IWDN.)

Yeah I guess I will just try to use the tutorials and such because our library and the libraries around for miles don't have any Python books.

You can learn Python without a book, start here:

http://wiki.python.org/moin/BeginnersGuide
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers

In fact, learning programming languages from online resources without needing to find and buy a book is probably a good habit to get into.

WHat is this needed for? To view Python?

Forget about httplib2 for now. Master the basics of Python first and then you can come back to more advanced topics like replacing the stock libraries. To write Python you can use any text editor. I would actually recommend against starting with an IDE.

Pattons3rd
June 29th, 2007, 18:42
Thanks for all the advice and help guys I really appreciate it.

I guess once I learn it I will try some of these things you guys are saying.

Would you recommend any particulaur IDE for this?

:D :D Thanks again for the help!!!!!:D :D

inimino
June 29th, 2007, 21:18
To write Python you can use any text editor. I would actually recommend against starting with an IDE.

Would you recommend any particulaur IDE for this?

I actually recommend not using an IDE. You'll be able to get started more quickly by just using a text editor. You can go through your first tutorial or two with Notepad, and you can download one of the text editors mentioned in the recent threads on that topic here on IWDN. Most programmer's editors have syntax highlighting, which will help you spot syntax errors as you learn, although Python syntax is very simple.

BigBison
June 30th, 2007, 06:59
In fact, learning programming languages from online resources without needing to find and buy a book is probably a good habit to get into.

Some people are more comfortable learning computer science from books, of course the examples are always hands-on. I'm that way, because I learned programming years before I went online. Classics by Knuth, Kozen, Sipser and standby references like "Data Structures in C" aren't online as far as I know.

http://dubinko.info/blog/2007/06/28/what-does-continuing-education-mean-to-you/

I came across that today, not only is this book (http://mitpress.mit.edu/sicp/full-text/book/book.html) online but there's even a video lecture series (http://feeds.feedburner.com/SICP) which is a nice companion to any of the standard texts.

Pattons3rd
June 30th, 2007, 17:29
Ok, I will just use what I have for now.
Thanks for being patient with me! :blush:

inimino
July 5th, 2007, 22:20
Classics by Knuth, Kozen, Sipser and standby references like "Data Structures in C" aren't online as far as I know.

That's an excellent point. These classic texts are available in many libraries, and are also worth owning, although they can be expensive. The books I would recommend against are the titles like "Teach yourself language X in 24 hours", where typically you would be better served by online tutorials and a comprehensive language reference (both of which are available online in the case of Python). A book that you can digest in 24 hours is not likely to be a good investment or either $50 or of 24 hours. However, something like the Knuth, where one volume can keep you busy for weeks or months, and still teach you new things years later, is a bargain both in cost and time invested.

absolethe
July 6th, 2007, 00:56
I hesitate to contradict the experts, but the vast majority of shared hosting out there seems to prefer a basic PHP/MySQL on Apache setup. There's a wide user base to offer support and advice on this sort of a "platform"--many of whom are not so technical as to talk over your head. It's widely available and easy to find tutorials. I'm not suggesting using it over the platform BigBison and inimino are suggesting. They know far more than me about this sort of thing.

BB, I have the utmost respect for you, but I don't understand what you're saying at least a quarter of the time. I'm not a programmer and never have been--I was completely surprised that I was able to learn as much PHP as I have. I'm not sure I ever will be a "programmer". For example, I honestly haven't a clue about OOP; can't read it even when it's PHP.

So although I will consider what I've just read, I'm not really sure "forget the arguably most popular server-side language on the web and do something completely different" is the most relevant advice. Though I understand that from your point of view it may be far more constructive for me than continuing to use PHP. ;)

I'm curious by nature and I LOVE the web. I want to be able to do everything: design, program, and be a server administrator. Unfortunately, I question whether I will ever have the time, energy, or even the inherent mental ability required. You can understand that I get a little overwhelmed since there are so many other things to consider. The company I'm now working for uses Java/Java Server Pages on Solaris (or something like that). .NET seems to be getting pretty popular and widespread, and it has all those languages available...ASP, C#, etc. What do I choose? It's kind of a moot point for me since I just don't have the time to tackle ANYTHING that new to me right now.

I hate feeling inadequate. And this is an area in which I perpetually feel inadequate. So though I hate to say it, if I am to really understand the benefits of your suggestion, I'll need you to dumb it down for me. *shudder*

BigBison
July 7th, 2007, 08:44
I hesitate to contradict the experts, but the vast majority of shared hosting out there seems to prefer a basic PHP/MySQL on Apache setup.

Because that's the only thing any of the third-party support outsourcing operations understand, or that's the only thing the in-house support has ever learned. PHP has been around for a while, and isn't going anywhere anytime soon. But you have to make a choice -- do you stick with PHP or do you learn something else with more technical merit? Ten years ago, all your arguments in favor of PHP applied to Perl, and nobody used PHP for the same reasons you give for not wanting to use something besides PHP today, by the way. :)

Hitching your wagon to yesterday's technology may have its advantages today, but those advantages could be totally outweighed in five years when most people are using anything but PHP and you're only still using it because of technology lock-in. As long as you understand the options you must weigh to make an educated technology decision, I'm happy.

BB, I have the utmost respect for you, but I don't understand what you're saying at least a quarter of the time.

...

I hate feeling inadequate. And this is an area in which I perpetually feel inadequate. So though I hate to say it, if I am to really understand the benefits of your suggestion, I'll need you to dumb it down for me. *shudder*

It isn't my intent to make anyone feel inadequate, I'm just not very good at putting technical things in non-technical terms. I was good at it when I was younger, but I've lost my ability to relate, sorry. So I figure I'll just give the technical explanations and either let others translate, or those who don't understand what I'm saying today might just develop that ability in a few months and come back to my post and understand it -- in fact, I get lots of PM and e-mail feedback along those lines. I'm afraid if I butcher dumbing something down, I'll be accused of condescending, so my policy is not to talk down to my audience. I try to make up for it by being patient with the questions that result.

http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm

Inadequate is exactly how I feel about REST. Every few months I study the same document again, and every time the meaning of it becomes more clear, and I'm at the point now where I realize I couldn't have said it any better or more clearly myself (although a year ago I was saying rather loudly that someone needed to do just that). The document hasn't changed, I've just developed the ability to understand it gradually over time while using it as a guide for what to study, all the while hoping it wouldn't be something I just won't ever be able to figure out -- like Calculus, or playing guitar.

Thanks for letting us know a bit better, where you are coming from, because there's really no indication in your posts (at least the ones I've read) to let me know that you aren't ready to jump right in to something like Django, particularly if you're into HTTP response code correctness... so please don't take my technical responses the wrong way, that's "just me being me".

inimino
July 9th, 2007, 11:16
I hesitate to contradict the experts, but the vast majority of shared hosting out there seems to prefer a basic PHP/MySQL on Apache setup.

That's a simple business decision. It does not follow that what would be best for you personally to learn is the same as what most hosting providers find it best to support.

You can consider a programming language in terms of what it allows you to do, or in terms of what it will teach you about programming. In terms of what you can do on the Web, Python and PHP are roughly indistinguishable. You can use both to build Web pages, connect to a database, and so forth. In terms of being a good introduction to programming concepts, I find Python to be preferable because it's a clean and elegant language whereas PHP feels like a series of kludges (which is consistent with that language's history). The difference isn't huge however, and there's nothing wrong with learning PHP, it's just perhaps not the straightest possible path to achieving enlightenment. The beginning programmer won't know that until learning several other languages, though. ;) There's also Ruby, and plenty of other choices...

absolethe
July 11th, 2007, 21:24
I'm having a lot of trouble deciding where to go next. I'm not really sure I want to be a "programmer", but I do find the subject interesting. And I hate running into walls--finding there's something I just can't do or just can't understand.

I considered learning C++ just for programming concepts (I definitely don't know much of anything about the inherent merits of one language over another). I even took a class, but for some reason the first class ignored object orientation. So it didn't serve the purpose I was hoping, which was to introduce me to that kind of programming.

A month or so ago I was going to try to learn about XML, XPath, and XSLT. I started, but I got this new job (which is taking up most of my time and energy).

Then I thought, maybe it would be better to start trying to learn an object-oriented language. But like what? PHP 5 apparently improved that, so I could stick with something I already know a little and try to learn what OOP is all about. But then several people have suggested Java as a better alternative (as well as a good thing to know). And that's what they use at work...sorta... Not that I want to move to engineering or anything.

But you two are both suggesting Python on its merits. For some reason I've been profoundly disinterested in Ruby since I first heard of it. Probably for no good reason. What would be best for me will probably ultimately be personal. But is it your opinion that Python would be a much better foundation for learning programming concepts and for the eventual acquisition of skills in other popular web languages?

It's true that I don't have time to jump into something huge. But I do have a to-do list. I assume I will address a major item on it before the end of the year. It's what to put next that I'm finding a difficult decision. For example, I think I've been neglecting the design part of my brain the last two years or so.

There are too many options for me. ;)

(Keeping in mind that I'm still not "technical enough", I kind of understand what you mean about Perl. When I was first getting into web design, all I saw for sever-side scripting was about Perl. And yet now it seems it's far less popular.)

inimino
July 12th, 2007, 01:13
C++ is object-oriented programming done wrong. Some years ago, C++ was the basic entry-level skill a commodity programmer needed, now it's Java. If that's what you want to be, then learn Java, but if you want to learn a language to learn programming concepts, C++ is emphatically not what you want, nor is Java.

Learning C would be a better investment of your time. The only thing added in C++ that I consider an improvement is the STL, which, while brilliant, wasn't widely used, and wasn't worth learning C++ for even then, and certainly not now.

If you want to learn programming at a somewhat higher level, a few languages to consider are Scheme, Erlang, Haskell, and ECMAScript. All of these are fundamentally different and will teach you ways of thinking that Java will not.

Python supports various programming styles, so you may learn different things depending on how you approach it. Something like Haskell or Scheme or Java comes with a very specific paradigm, so a programmer who learns one of those languages will learn a very specific approach. Python is a little looser, for example, you can use class-based OOP, or not, and you can use some functional programming constructs, or not. None of those approaches is really essential to Python, however. Python is a kind of plain-vanilla structured imperative language with various other features attached.

If you want to learn something that will have immediate practical benefit and also teach you something worth learning about programming, give serious consideration to ECMAScript. Unfortunately there is very little in the way of good online introductory documentation about this language. The ECMA-262 specification is quite good but almost entirely indigestible without considerable existing experience.

If you don't want to really learn programming but just want to be able to do simple server-side stuff now and then, just learning a little more PHP is best. From what I've seen you pick up from Apache and PHP documentation, I think there is some more potential in you that wants to get out. But it's a personal thing, and there are indeed many options. What do you want to be able to accomplish? Do you want to make a good living? Change the world? Be intellectually satisfied? What do you want to do with your life?

absolethe
July 13th, 2007, 17:57
How'd we get to what I want to do with my life? ;) I'm not sure if I should be moving this to a PM or something, but...

Well, as I mentioned, I love the web. I came into an interest in it as a web designer. I always wanted to be an artist, but I can't draw for crap. (Well, or a writer, but I've had writer's block for the better part of a decade.)

Web design got me interested in knowing at least a little about graphic design (for print). But I found print production considerations a bit tedious--at least in class--so I knew I wanted to focus on the web.

But I'm also curious and the fact that I couldn't do certain things without the benefit of someone else's programming (like e-mail forms) bothered me. One thing I learned ended up leading to another. So many things interact to create the experience of browsing a site... I feel that I can't be the best and most effective web designer/web...whatever possible without having an understanding of the whole 'package'.

I'd like to be a "jack of all trades." What I want to avoid is being "a master of none." So all my exploration of programming has been to learn how to do something on a site. And if it doesn't have any direct application for a web site, it's not a priority. (I figure some digression is necessary and helpful in learning and understanding concepts. I'm just trying not to lose focus.)

I'm pretty satisfied with what I can do with PHP. So far I've been able to accomplish whatever I tried to do with it PHP and MySQL. Until this status code thing. ;) But I can't really collaborate with others because OOP is such a big thing and I don't do things that way.

As exciting as I've found learning PHP and making my site database driven, I don't want to FOCUS on programming as a lifestyle or career choice. I do want to be well-rounded--I guess that's intellectual satisfaction. ;)

But I don't want my design skills to wither (well, if I had any to begin with). I've met people who started out as designers and ended up in server administration-esque or programming-esque careers. I definitely want to continue to focus on the web design over those topics. Luckily I'm doing a fairly significant amount of design at work, so that should help me balance my extracurricular studies.

Maybe I'll never be like BigBison and be able talk about the best way to write tables for effective rendering the browser based on my own knowledge. ;)

What you said about Python makes it sound attractive. In my head, I've been thinking that I do want to learn more about "programming concepts." But I am afraid of piling too much on my plate.

(And of course I want to make a good living! But I'm not terribly ambitious in that regard. I just want to be able to fix my car if it breaks, buy toys for my dogs, and books for myself. :) )

inimino
July 16th, 2007, 08:59
Curiosity is a funny thing, you never know where you may end up. ;)

Perhaps the best advice I can give you is to pick a project that requires some programming, and then pick a language that's appropriate to that project and learn the language by completing your project. In my opinion, the best way to learn a programming langauge is with a specific project. Learning a language that you have no immediate use for is probably not the best use of your time.

You mentioned collaboration and OOP, are you more interested in projects you can complete on your own, or in being part of a team? Unless you're going to change careers, I would guess the former, and this can affect your choice of languages as well. Many of the design decisions of a language like Java were intended to facilitate collaboration and maintenance of code over long periods of time by multiple developers, and may not benefit you in projects you can complete yourself.

If there's a specific existing project you want to contribute to, perhaps an open-source CMS that is missing some features, that can be a good way to learn a programming language as well.