473,396 Members | 1,975 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,396 software developers and data experts.

Modifying and posting uri

How can I take a uri passed to a interface script(a script that is called
for every page request) modify it, do whatever, and then change the uri that
the user see's to be whatever?

Essentially I have a rewrite rule

RewriteRule ^(.*)[/]?$ /Index\.php

That calls index.php

I can do $_Server['REQUEST_URI'] to get the uri but how can I modify the
browser's uri that the user see's but also redirect the uri to something
different.

Basically I sorta want to write a rewrite handler of my own because I'm
having a few issues with it. I'd rather use php to deal with it if possible.

Thanks,
Jon


May 5 '07 #1
5 2071

"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:UB*******************@newssvr12.news.prodigy. net...
How can I take a uri passed to a interface script(a script that is called
for every page request) modify it, do whatever, and then change the uri
that the user see's to be whatever?

Essentially I have a rewrite rule

RewriteRule ^(.*)[/]?$ /Index\.php

That calls index.php

I can do $_Server['REQUEST_URI'] to get the uri but how can I modify the
browser's uri that the user see's but also redirect the uri to something
different.

Basically I sorta want to write a rewrite handler of my own because I'm
having a few issues with it. I'd rather use php to deal with it if
possible.

Thanks,
Jon
Essentially what I would like to do is modify the uri with something like

$_Server['REQUEST_URI'] = '/MyPage/';

(as an example)

and it update the browsers uri but not effect anything else. (ofcourse if
they uset that uri I will need to make sure it maps to something)

I know I can use rewrite rules and I'm trying to I am having more problems
with them than it should be and I can handle it a lot easier in php(And
atleast debug it so I know why things are failing).
May 5 '07 #2
Jon Slaughter wrote:
"Jon Slaughter" <Jo***********@Hotmail.comwrote in message
news:UB*******************@newssvr12.news.prodigy. net...
>How can I take a uri passed to a interface script(a script that is called
for every page request) modify it, do whatever, and then change the uri
that the user see's to be whatever?

Essentially I have a rewrite rule

RewriteRule ^(.*)[/]?$ /Index\.php

That calls index.php

I can do $_Server['REQUEST_URI'] to get the uri but how can I modify the
browser's uri that the user see's but also redirect the uri to something
different.

Basically I sorta want to write a rewrite handler of my own because I'm
having a few issues with it. I'd rather use php to deal with it if
possible.

Thanks,
Jon

Essentially what I would like to do is modify the uri with something like

$_Server['REQUEST_URI'] = '/MyPage/';

(as an example)

and it update the browsers uri but not effect anything else. (ofcourse if
they uset that uri I will need to make sure it maps to something)

I know I can use rewrite rules and I'm trying to I am having more problems
with them than it should be and I can handle it a lot easier in php(And
atleast debug it so I know why things are failing).

You'll have to do this from the Apache end, not the client or your script.

The URI in the browser is what the browser uses to request the page.
You can't just change it without affecting what the browser requests.
So you'll have to have Apache change the request to something different.

You might be able to get some help in alt.apache.configuration.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
May 5 '07 #3
On May 5, 4:48 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Jon Slaughter wrote:
"Jon Slaughter" <Jon_Slaugh...@Hotmail.comwrote in message
news:UB*******************@newssvr12.news.prodigy. net...
How can I take a uri passed to a interface script(a script that is called
for every page request) modify it, do whatever, and then change the uri
that the user see's to be whatever?
Essentially I have a rewrite rule
RewriteRule ^(.*)[/]?$ /Index\.php
That calls index.php
I can do $_Server['REQUEST_URI'] to get the uri but how can I modify the
browser's uri that the user see's but also redirect the uri to something
different.
Basically I sorta want to write a rewrite handler of my own because I'm
having a few issues with it. I'd rather use php to deal with it if
possible.
Thanks,
Jon
Essentially what I would like to do is modify the uri with something like
$_Server['REQUEST_URI'] = '/MyPage/';
(as an example)
and it update the browsers uri but not effect anything else. (ofcourse if
they uset that uri I will need to make sure it maps to something)
I know I can use rewrite rules and I'm trying to I am having more problems
with them than it should be and I can handle it a lot easier in php(And
atleast debug it so I know why things are failing).

You'll have to do this from the Apache end, not the client or your script.

The URI in the browser is what the browser uses to request the page.
You can't just change it without affecting what the browser requests.
So you'll have to have Apache change the request to something different.

You might be able to get some help in alt.apache.configuration.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I think what John's asking is how to implement an MVC style approach,
and he's clearly got it working to a degree. A simple rewrite is
already in place on the server which directs all requests to the
Controller which then takes the value of this URI, and uses it to
"forward" the content (View).
However the changing of the URI in the address bar isnt really what
you need.
Your rewrites should not "redirect" [ with 30x status] to the control
script, instead is uses the [L] flag to supress the address bar
change. The address bar however does change because all the links in
your application are generated by the application which understands
the layout model of your app.

So firstly it doesnt matter how the site is laid out, because your
controller can be setup [not the best way obviously] to go where your
content already is, BUT your Views, the html that you want to be
displayed should ideally not be heavily mixed with php that is written
for that page only and which contains absolute references to includes
[php classes etc...]. Instead you should hold the includes [database/
functions/classes etc...] all somewhere central, the references inside
the html [to things like images/css/js ...] should ideally all be
relative to the app root.
Then say you have a structure like this

/
/Music
Main.php
/Tutorials
MusicTheory.php
/Tutorials/MusicTheoryDefinitions.php

using an array of page->view templates it is obviously possible for
your controller to realise that when a request for
http://www.server.com/newapp/music/
(of the form /application/page/subpage/var1/var2/var3/ etc...)
comes in, it is to grab the URI, obtain the page, populate an array
with all the elements that the page should have (using the kind of
code that you probably have within /Music.php, and then find this
pages view [which is basically an empty html template with
placeholders for php variables] on the filesystem and include it,
which leads to the html output.

You are in a difficult situation because your code was written before
you thought about separation of code from content, so you have pages
which cannot just be included, or else various paths would be wrong,
but that would be one way to do this. Redirection using a header is
also one way but it will kill your page ranking - all those 302's) and
although changing the URLs as you wish doesnt address separation of
concerns (look and feel/programming ...)

My advice is to see this as a project, leave framesets behind,
concentrate on making the links generated by the MVC pattern human and
SE readable, and think about reducing the amount of repeated code
there is in each page, and try to abstract things like calls to mysql
and queries, in favour of building a query and passing it to a
function that makes the connection to the db and returns the query
results... after you have refactored your code, you will reap the
benefits of having implemented a true MVC pattern, and made your site
SO easy to maintain. (If you change to pgsql or decide to implement
security [login] you only have to update a single function, and a
small part of the model code. It might be work to refactor but it
really is worth it.

The Claw framework
http://claw.tigris.org/
which uses a Hierachical Model View Controller framework, is a great
example of what we are talking about, it too uses a single rewrite,
and then some decent code to abstract everything, it is a very nice
(but complex) piece of code I think. Look through the example
addressbook application, and the way the templates are held away from
the code that generates the rest of the html, how easy it would be to
add a few languages, etc... you will see!
May 6 '07 #4
Wouldn't your own 404 handler do that for you?

May 6 '07 #5
On May 6, 6:30 pm, ashore <shor...@gmail.comwrote:
Wouldn't your own 404 handler do that for you?
Off Topic?
please always quote before you reply to something, but in this
context, a 404 handler is not relevant.

May 6 '07 #6

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

Similar topics

16
by: Japcuh | last post by:
How do you write self modifying code in Java? Japcuh (Just Another Perl C Unix Hacker) http://www.catb.org/~esr/faq/hacker-howto.htm#what_is ..0. ...0 000
2
by: Jean-S?bastien Bolduc | last post by:
I'm afraid this is a silly question, to which I know the answer already. But let me ask anyway... In Python, is there a way to modify a builtin type's methods? for instance, modifying...
6
by: Peter Ballard | last post by:
Whew. I hope that title is descriptive! Hi all, The python tutorial tells me "It is not safe to modify the sequence being iterated over in the loop". But what if my list elements are mutable,...
2
by: QyRoN | last post by:
Hi I need to install python-2.3 on my computer. The problem is that python and many programs written in python (pythonwin for example) use registry for storing parameters on python installation....
2
by: Kirk Is | last post by:
Hi there. I'm trying to improve a simple javascript based graphics editor for Atari 2600 games (long story) with better use of CSS and Javascript. I'm a little weak on what CSS can and can't...
2
by: Gaz | last post by:
....and recompiling it again Hi all, I've got an Assembly DLL and associated .NetModules and want to amend a function in one of the .NetModules I've used ILDASM to decompile the .NetModules...
2
by: VM | last post by:
Can I manually modify the Display Properties->ScreenSaver tab values from within aWindows C# application? During setup of my screensaver, I'd like to be able to configure this tab (specifically,...
3
by: Martin | last post by:
I'm trying to paint my own caption bar/title bar and also my own frame border, but I'm having problems with modifying the clip region so windows doesn't paint over my stuff when I call base.WndProc...
1
by: A.M-SG | last post by:
Hi, Can I view/modify SOAP message at the client proxy side without using soap extensions? Thank you,
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.