473,386 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Simpler urls

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. 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

<?php
function chk_screen(){
$default_screen = 'home.php'; # the default screen
if(isset($_REQUEST['SC'])) {
if(is_file(SCREEN_DIR . "/" . basename($_REQUEST['SC']))) {
$SCREEN = basename($_REQUEST['SC']);
} else {
$SCREEN = $default_screen;
}

if($SCREEN == 'main.php') {
$SCREEN = 'home.php';
$_REQUEST['SC'] = $SCREEN;
}
} else {
$SCREEN = $default_screen;
}
return $SCREEN;
}?>

The images are stored in a folder heirarchy, there is no database but
I'm guessing I'll have to add one with an index & serial numbers for
each image. The folder structure is part of the properties of each image
though:
&DIR=California/Bay-Area/San-Francisco/neighborhoods/2007-06-19-stanyan
then the url gets this too:
&PG=1&PIC=1

I'd like to see at most:
http://www.edgehill.net/California/B...19-stanyan/005
Ideally it could trim off most of that in hidden POST data?
(I forget how)

I could just try snipping off the "1/?SC=go.php&DIR=" and "&PG=1&PIC=1"
http://www.edgehill.net/stanyan/001

or add a database & use something like this:
http://www.edgehill.net/000001

Part of the effort is to create a fresh set of folders & the old archive
folders remain as the 'database' and sorted by location & date. One such
new folder could be a blog with my (usually weekly) photo updates, then
categories for nature, plants, landscapes, people.

I've built the collection with text files for captions & the folders
with date & location so I guess all that needs to go in a database & get
indexed.

--
Paul Furman Photography
http://www.edgehill.net/1
Bay Natives Nursery
http://www.baynatives.com
Jul 10 '07 #1
7 1532
NC
On Jul 10, 3:56 pm, Paul Furman <p...@-edgehill.netwrote:
>
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. 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
[skipped]
I'd like to see at most:
http://www.edgehill.net/California/B...San-Francisco/[skipped]
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.

Cheers,
NC

Jul 10 '07 #2
Rik
>>Hence, the links:
>>>
http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
Ack... regular expressions!!!!!!!!!
Anyone interested in a little consulting to get me up to speed on a
basic framework for this system, please email. I've got a couple web
sites that could use this upgrade but it's beyond me for now to even
get a basic effect to take hold with .htaccess on the first one I tried.

I'd suggest you try asking in alt.apache.configuration. That's where
those gurus hang out.

There are a few here with knowledge about how to do it, but many more
over there.
Well, if htaccess isn't your thing, there's one other pretty easy brute
force thing to do:

Simple htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L,QSA]

This will throw requests for non-existant files or folders to your
index.php. Search the $_SERVER['REQUEST_URI'] for the original request,
and have fun in PHP instead of .htaccess. Exploding, loops, databases, all
at your disposal.

If the request doesn't make sense, please throw out a not-found header in
PHP, search engines generally appreciate that. And realise your server
will have a lot more heavier load in this setup, as the webserver itself
isn't responsible anymore for it's own fast returns, but everything goes
through PHP.

HTH
--
Rik Wasmus
Jul 17 '07 #3
Sorry, that was supposed to go to alt.apache.configuration

Paul Furman wrote:
Hi, can someone help me with consulting to migrate to a RewriteEngine
configuration? This looks like more than I can bite off, I could use
some help.

Thanks,
Paul

Jerry Stuckle wrote:
>
I'd suggest you try asking in alt.apache.configuration.
Jul 17 '07 #4
Paul Furman wrote:
Sorry, that was supposed to go to alt.apache.configuration

Paul Furman wrote:
>Hi, can someone help me with consulting to migrate to a RewriteEngine
configuration? This looks like more than I can bite off, I could use
some help.

Thanks,
Paul

Jerry Stuckle wrote:
> >
I'd suggest you try asking in alt.apache.configuration.
:-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '07 #5
NC wrote:
Paul Furman 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. 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/B...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.
Hmm, OK I looked into this some more and it doesn't appear to be
practical because I have a huge number of destination urls & as I
understand, I'd need to actually list all those in the .htaccess file.
It seems I might be better off doing my own parsing in php which also
would not be easy but then I could direct things more flexibly &
accommodate any number of destination urls. Does this sound right?

--
Paul Furman Photography
http://www.edgehill.net/1
Bay Natives Nursery
http://www.baynatives.com
Jul 21 '07 #6
..oO(Paul Furman)
>Hmm, OK I looked into this some more and it doesn't appear to be
practical because I have a huge number of destination urls & as I
understand, I'd need to actually list all those in the .htaccess file.
This depends on the URLs. Of course listing all possible URLs is
absolutely pointless. That's not what regular expressions are for.
But if there would be a common structure inside them, like

http://example.com/state/area/city

you could easily match all of them with a single regular expression.

Micha
Jul 22 '07 #7
Michael Fesser wrote:
.oO(Paul Furman)

>>Hmm, OK I looked into this some more and it doesn't appear to be
practical because I have a huge number of destination urls & as I
understand, I'd need to actually list all those in the .htaccess file.


This depends on the URLs. Of course listing all possible URLs is
absolutely pointless. That's not what regular expressions are for.
But if there would be a common structure inside them, like

http://example.com/state/area/city

you could easily match all of them with a single regular expression.
Just a followup, I found a consultant to tutor me through this and I got
away with just rewriting the top level folders in .htaccess then
allowing any number of subfolders to be appended. Here's what it looks like:

RewriteRule ^gallery/?$
index.php?SC=go.php&DIR=0_gallery [NC]

RewriteRule ^gallery/Photo-Update(/.+)?$
index.php?SC=go.php&DIR=0_gallery/0-Photo-Update$1 [NC]

RewriteRule ^gallery/(.+)$
index.php?SC=go.php&DIR=0_gallery/$1 [NC]

Then I also have to go back & rewite my links to the new format. I'm
still working out plenty of bugs but I got the basic thing rolling.

--
Paul Furman Photography
http://www.edgehill.net/1
Bay Natives Nursery
http://www.baynatives.com
Jul 23 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: phpkid | last post by:
Howdy I've been given conflicting answers about search engines picking up urls like: http://mysite.com/index.php?var1=1&var2=2&var3=3 Do search engines pick up these urls? I've been considering...
26
by: Howard Brazee | last post by:
I would like to click on a URL of a html document that will open several URLs at once for me. Does someone have an example of a html document that will do this?
1
by: DM | last post by:
I'm working on a site with more than 1700 HTML files. We'll be moving files around on this site a lot because we're reorganizing it. I'm thinking of writing a script that will convert all URLs in...
7
by: AES | last post by:
Encountered a URL containing a comma the other day -- the first time I've ever noticed that, so far as I can recall. It worked fine, however, and I gather commas are legal in URLs. Out of...
10
by: jflash | last post by:
Hello all, I feel dumb having to ask this question in the first place, but I just can not figure it out. I am wanting to set my site up using dynamic urls (I'm assuming that's what they're...
9
by: Salve =?iso-8859-1?Q?H=E5kedal?= | last post by:
What is the best regular expression for finding urls in plain text files? (By urls I mean http://www.something.com, but also www.something.com, or salve@somewhere.com) Salve
2
by: Simon Wigzell | last post by:
I have inherited a database driven website that comes with a table of image links. The images are scattered all of the internet and there are thousands of them. I would like to write an asp script...
3
by: WebCM | last post by:
How to apply nice URL-s into CMS? 1. Should we use nice urls for every page? 2. Do we need to put a FULL path into <a href="">? 3. What is faster and better? a) 10 rules in .htaccess...
4
by: Guy Macon | last post by:
As a personal learning experience with limited practical use, I have been doing some experiments with using .htaccess to redirect mis-typed URLs to a preferred canonical form. I have set up a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.