Page 1 of 1

user friendly urls

Posted: Tue Jan 27, 2004 9:32 am
by Nay
i'm getting into SEO and also digging into the other worlds of PHP and Apache. i recently read:

https://www.zend.com/zend/trick/tricks- ... 3-urls.php

my question is that is it possible without needing to do it in the httpd.conf? like, using a .htaccess file instead. the other thing that worries me is that invision board and other things that are not my script does not run in this type of url, im assuming that would affect it? also, is i'd like to hear your opinions on why/why not using this type of URLs.

thanks,

-Nay

Posted: Tue Jan 27, 2004 9:54 am
by ilovetoast
There are several ways to do this with Apache. You can use the Zend-described method with the Files, ForceType and AcceptPathInfo directives and a PHP script.

Or.... you can do it using just mod_rewrite (and just 3 lines in the conf file). Leave it to Zend to give you great info, and then set about doing it using the most obscure method they can.

Nay: you cannot do this with .htaccess. This is intended to be done with the aide of Apache and really shouldn't be done/can't be done as effectively any other way.

The first reason I don't use it is that the SEO benefits of this are suspect at best. Very suspect. The second is I don't care if the user likes how the URL looks for some deep interior page-- this just makes it easier for them to play with it manually (and if we really wanted them to do that we wouldn't have any links anywhere on our sites- we'd just let them guess). The third is I don't use many GETs.

For the best SEO info site on the Net, IMHO, check out http://www.bruceclay.com. I don't buy his services and I don't recommend you buy them either, but he has a ton of current info as well as a host of USEFUL free tools. His site is a hefty read, but 1000x better than those silly mass submission pyramid schemes out there.

peace

Posted: Tue Jan 27, 2004 10:14 am
by Nay
Thanks for the reply. I asked since I'm on a shared web host. So in turn I don't get direct access to the httpd.conf. My knowledge of Apache is to place .htaccess where needed changing. From my other <cough>limited</cough> knowledge is that mod_rewrite is done by .htaccess? No? Oh well.

Anyway, the most important I'd ask is the 'other scripts' thing. Say my forums which is:

http://frozenashes.net/forums/index.php?foo=bar

Would it still work? I assume it would since 'forums' is not defined as a php file for Apache?

-Nay

Posted: Tue Jan 27, 2004 4:51 pm
by ilovetoast
The mod_rewrite you need to do for this involve changes to the Apache conf file.

I'm sorry but I don't follow your "would it still work question"...

peace

Posted: Tue Jan 27, 2004 5:03 pm
by jaxn
Actually you can do it in .htaccess (sometimes).

If in the httpd.conf the MultiViews and FollowSymLinks are on for your directory, then you can use clean urls by adding a FILES declaration in your .htaccess.

Some hosts allow it, others don't. If you ask nicely they may be willing to turn it on for you depending on their setup.

Also, when using the FILES method it is easy to run appps with clean urls along side apps without. It doesn't have to be an all or none.

Why would you want to use clean urls? I use them for AltaVista indexing since they are more likely to index pages without querystring vars. But the only search engine that really matters is Google and they don't mind query strings.

The other reason is to allow your UI to extend to the location bar. I use clean URLs as a type of breadcrumbs.

-Jackson

Posted: Tue Jan 27, 2004 6:22 pm
by ilovetoast
To do this with .htaccess is possible if the conf file is set right, but, as I said:
The mod_rewrite you need to do for this involve changes to the Apache conf file.
You can kludge ;) together some .htaccess files in assorted directories if you are fortunate enough to have the conf file set up correctly for that, but unfortunate enough to have access to it yourself.

Using mod-rewrite only in the conf file does not require an all or none implementation. It is as customizable as any way of doing it.

I guess this is why I advocate all persons running a site of any decent size or importance (to anyone) should suck it up and pay for a hosting service that allows root access. :)

gl

a toasted bagel is not toast

Posted: Tue Jan 27, 2004 6:50 pm
by jason
Honestly, I have never seen the beneift of "user friendly url's". I think it's a myth.

First, URL's are far from friendly. They are confusing, long and not at all "user friendly". Phone numbers are even more friendly than URL's. A URL's saving grace is name recognition.

But have you ever tried to send someone to something like "http://subdomain.example.com". You have the problem that some people will throw the http:// in there, but others will ask: "h-t-t-p?". Then they will always type in "www". Even if you tell them to type in "subdomain.example.com", they will prepend "www" to it. Even if you spell it out.

And as soon as you say forward slash, that confuses them. I have seen people stumble on this. They type a backslash instead, and I have to correct them. This usually means I also have to explain to them the difference between / and \.

Anyways, try giving them directories, and then explaining "uppercase or lowercase".

URL's are just evil.

It's better to have a clean interface on your site. It's a lot easier to tell someone to go to example.com, click on the products button, and then click on the "Printers", and then click on the "XJ-50 Model" than it would be to tell them to go to "example.com/Products/Printers/XJ50".

Because what happens when someone types in "example.com/Products/Printrs/XJ50"? Can your program handle that? Suddenly the person is plunged into a dark space.

Anyways, this thread isn't about usability, but about SEO. And you know what, I really don't buy this. I think it's a holdover from yesteryears, when search engines couldn't handle anything past "?". But this is no longer the case. In the sites that I run, having a normal ? and & url doesn't appear to be a hinderance. Today, it's less about the URL, and more about getting linked.

Why would I be against these types of URL's you guys are discussing? Having worked with them myself, I can say that they take a lot more work to setup, and work with, than normal URL's, and at least for me, they became a bigger problem than they were worth. Remember, by going the route of using something like mod_rewrite, you are introducing one more tool into the mix of tools that are needed to run the site. And the more things you introduce, the better chance there is of something going wrong.

Don't get me wrong, mod_rewrite is a great and stable tool. But from a purely production point of view, I didn't find it as useful as you might think. I think more time should be spent in the user interface of the site, assisting the user in navigating to where they want to go. If the user has to go to the URL to make the change, my site has failed.

Posted: Thu Jan 29, 2004 8:20 am
by Nay
Thanks for the input. I've been offline the past day since my landlord paid the line bill late and my account was suspended. hmmm....

Anyhow, I'm still deciding to-use or not to use part. I've not done much at all with the friendly URL's so I want to research more into it. On my localhost, somehow, if I type:

http://localhost/index

or

http://localhost/index/this/stuff/is/fake

It's the same as:

http://localhost/index.php

I hunted down my httpd.conf but not much luck finding what was the trick. Jaxn, I'd like it if you can go more in depth on:
If in the httpd.conf the MultiViews and FollowSymLinks are on for your directory, then you can use clean urls by adding a FILES declaration in your .htaccess.
ilovetoast, I was refering to:
Also, when using the FILES method it is easy to run appps with clean urls along side apps without. It doesn't have to be an all or none.
with my second question. I was thinking would the non-friendly URL scripts would go whack if I turned on using friendly URLs.

-Nay

Posted: Thu Jan 29, 2004 9:46 am
by jaxn
Nay,

In your httpd.conf file there is a section that looks something like:

Code: Select all

<Directory /path/to/your/web/root/>
#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
    Options -Indexes FollowSymLinks MultiViews
#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
    AllowOverride All

</Directory>
In the Directory block for your host/vhost you need to either:
- have FollowSymLinks and Multiviews listed in the Options row
or
- have AllowOverride set to All or Options

If you have FollowSymLinks and MultiViews on in the httpd.conf then you can just add a Files directive to your .htaccess. Otherwise, with AllowOverride set to all or options you can set the FollowSymLinks and MultiViews options in your .htaccess.

Once your directory is set right, then you can add a Files setting to your .htaccess that will look something like:

Code: Select all

<Files app>
   ForceType application/x-httpd-php
</Files>
What I then do is create a symbolic link from app to index.php. However you can skip the symbolic link part and just use a file named "app" with no file extension.

Since this way affects no files other than "app", all other scripts will still run fine.

Hope that answers your questions. Just let me know if something is vague.

-Jackson

Posted: Thu Jan 29, 2004 10:00 am
by Nay
hmmm, I dropped:

Code: Select all

<Files index>
   ForceType application/x-httpd-php
</Files>
Into the sub dir at:

http://frozenashes.net/blogring/main/

Well, these work fine:

http://frozenashes.net/blogring/main/
http://frozenashes.net/blogring/main/index

When I do:

http://frozenashes.net/blogring/main/index/
or
http://frozenashes.net/blogring/main/index/bla/bla/bla

The thing still shows but the images and css go wack. On my local server that doesn't happen. My local server's conf has:

Code: Select all

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/AppServ/www">

#
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
    Options Indexes FollowSymLinks MultiViews ExecCGI

#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo", 
# "AuthConfig", and "Limit"
#
    AllowOverride All

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all
</Directory>
I'm not sure how to check the httpd.conf for my host's server O.o..

-Nay

Posted: Thu Jan 29, 2004 10:32 am
by jaxn
You got the httpd.conf correct, so don't worry about it.

The images and css are because you are using relative links (../images/myimg.gif).

Make all of your images and css files either absolute urls or relative to the site root and you will be fine.

-Jackson

Posted: Thu Jan 29, 2004 10:34 am
by Nay
<cough>local server</cough>. That's http://localhost/. Also http://127.0.0.1.....

lol, anyhow, so I guess there's not much of a way to view stuff in httpd.conf without mailing my host and waiting a month for their reply? heh...

Well, I guess it's technicly working. hmm...

-Nay

Posted: Thu Jan 29, 2004 11:19 am
by jaxn
No really, I went to the URL that you posted. You don't need to alter the httpd.conf on that server.

The css will work if you change it from :

Code: Select all

<link rel="stylesheet" type="text/css" href="index_2.css" />
to

Code: Select all

<link rel="stylesheet" type="text/css" href="http://frozenashes.net/blogring/main/index_2.css" />
or

Code: Select all

<link rel="stylesheet" type="text/css" href="/blogring/main/index_2.css" />
Now, if frozenashes.net is the host you are talking about then your problem is solved. If you are trying on another server then I would have to see what it is doing.

-Jackson

Posted: Thu Jan 29, 2004 11:29 am
by Nay
Yeah, I guess I'd set my template parser to replace full URL's. The project is for my friend. His hosting isn't up yet. So until he gets it, I'm quite limited from building the front end. Ah, oh well, there's plenty to do on the backend I guess O.o..

Thanks anyway,

I'll post once I've tested it on his host...

-Nay