Re: Simpler urls



NC wrote:

On Jul 10, 3:56 pm, Paul Furman <p...@xxxxxxxxxxxxx> wrote:

I want to have urls that work like the php.net
pages where there's just a word after a slash,
maybe a few folders deep.

This has almost nothing to do with PHP.

OK so no considerations for my php coding? I'm passing paths every which way, that'd be great if I didn't have to update any of that.

This is a HTTP server-level
problem. Apache has a module called mod_rewrite, which can be
configured to accomplish what you want:

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

Right now I've got urls & code like this:
http://www.edgehill.net/1/?SC=go.php&DIR=California

But I'd prefer:
http://www.edgehill.net/California

I'd like to see at most:
http://www.edgehill.net/California/Bay-Area/San-Francisco/

If your hosting company allows .htaccess files, add these lines to
your .htaccess file in the site's root directory:

RewriteEngine on
RewriteRule ^California(.*)$ /1/?SC=go.php&DIR=California$1 [NC,L]

This should do the trick.

Looks cool, from what I can tell, the only thing to learn is the syntax & rule evaluating order. Sounds like I could set up however big an htaccess file to identify my simplified structure but maybe at some point it would take a hit on performance... or not if I figure out how to tell it to stop searching the rule list. Maybe the 'index' I talked about before would become a long well-sorted rule list that I run through php after making updates to regenerate the index?

<http://www.edgehill.net/1/?SC=go.php&DIR=California/Bay-Area/San-Francisco>
becomes
<http://www.edgehill.net/San-Francisco>
-this type I'd have to generate by choice

<http://www.edgehill.net/1/?SC=go.php&DIR=California/Bay-Area/San-Francisco/neighborhoods/2007-06-19-stanyan&PG=1&PIC=1>

becomes
<http://www.edgehill.net/2007-06-19-stanyan/1/1>
-this type I'd like to generate automatically, if I had a repeat named subfolder that would cripple it, but that's a rare situation. Each addition to the photo library sits under some number of folders with a name like: '2007-06-19-location' sometimes only with the date in which case the indexer would build something like 'stanyan/2007-06-19'.

This should also maintain the old navagation system, as soon as someone hits a full archive path, the url will convert to whatever shortcut overrides in the htaccess file as long as it's indexed. If it's not an indexed folder yet, it reads as is. It's possible I could create dead end folders with no links to them but not normally a problem.

--
Paul Furman Photography
http://www.edgehill.net/1
Bay Natives Nursery
http://www.baynatives.com
.



Relevant Pages

  • Re: Window Server 2003 R2 x64 Std Apache/PHP/Tomcat Security
    ... and PHP Security and Security of Tomcat. ... In my installation with Apache 2 and PHP 5 is possible to make/list folder/files to C: root and every where in server. ... How to I setup these user settings like there only to possible to make things above only in wanted folders and exec function can be used only for run chosen applications. ...
    (microsoft.public.windows.server.security)
  • RE: [PHP] Readdir() question
    ... (or similar depending on your needs, you might also want a folders ... The advantages of mapping real files in a virtual location is that you ... For an upload system you would need to write a PHP script on the ... got to do it in the scheduled job, ...
    (php.general)
  • Read Only Problems
    ... on some of my folders. ... PHP in dealing with news on my homepage. ... and windows makes the folder a read-only ... folder...i try to uncheck the read-only attribute and it ...
    (microsoft.public.windowsxp.security_admin)
  • read only problems
    ... on some of my folders. ... PHP in dealing with news on my homepage. ... and windows makes the folder a read-only ... folder...i try to uncheck the read-only attribute and it ...
    (microsoft.public.windowsxp.security_admin)
  • Re: use of random alphanumeric folder names
    ... company I can see 2 folders, ... and use php to deliver the files from fred to ... suggestion whatsoever!!!! ... But he said put the .htaccess file in public_html! ...
    (comp.lang.php)