Optionally supporting mod_rewrite
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Optionally supporting mod_rewrite
What methods do you use when your application uses mod_rewrite but you wish to provide a failsafe backup incase mod_rewrite is disabled???
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
You really don't feel like spending much time replying to me tonight do you?feyd wrote:
- path info
- normal links
For instance a less than ideal method might consist of template logic which checks for mod_rewrite and outputs a link accordingly...a better approach might be using the same technique that session funcitons do when cookies aren't available...
What technique do you use...maybe something better than the above...which I'd love to hear...
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
The concept is to have a class for each link type and detection code that can tell you which is best to use for any given page request. So long as you have a unified way of referencing files, it shouldn't be too much of a problem for it to handle all link generations.
I personally don't care about mod_rewrite or so called "search-engine-friendly" URLs.
I personally don't care about mod_rewrite or so called "search-engine-friendly" URLs.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- johno
- Forum Commoner
- Posts: 36
- Joined: Fri May 05, 2006 6:54 am
- Location: Bratislava/Slovakia
- Contact:
Try http://www.example.com/?somepath/anotherpath/ and look at $_SERVER['QUERY_STRING'];
First, make sure you use the mod_rewrite flags QSA and L
then because the query arguments are being secretly passed still as variables you can use like normal ( eg. $_REQUEST['first'], etc. ) simply develop a function in place of the actual URLS.
eg.
would be
Then in this function you can make a check for a mod_rewrite variable being set to ON or OFF.
Then based on that you can deliver the urls...
if mod_rewrite was on, the above code would output:
That's how I'd do it, but then again, I'd just say get mod_rewrite or don't use this app
then because the query arguments are being secretly passed still as variables you can use like normal ( eg. $_REQUEST['first'], etc. ) simply develop a function in place of the actual URLS.
eg.
Code: Select all
echo "blablabla.com/first/second/third/";Code: Select all
echo "blablabla.com/". ReWrite("first", "second", "third) ."/";Then based on that you can deliver the urls...
if mod_rewrite was on, the above code would output:
if mod_rewrite was off, the above code would output:blablabla.com/first/second/third/
and because it's a function, you can change variable names to be output based on what first variable was sent in for example, like a reverse mod_rewriteblablabla.com/index.php?variable1=first&variable2=second&variable3=third
That's how I'd do it, but then again, I'd just say get mod_rewrite or don't use this app
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Boom, thats brilliant!!!johno wrote:Try http://www.example.com/?somepath/anotherpath/ and look at $_SERVER['QUERY_STRING'];