I am new to using mod_rewrite and am trying to rewrite a URL to pass values to
my script so that: http://www.myclient.com/everything/animals/mammals/cats
is transformed into http://www.myclient.com/index.php?nav[0]=everything&nav[1]=animals&nav[2]=mammals@nav[3]=cats
Specifically, I am looking for an n-ary solution to this problem. I know how to
do it for a discrete number, but how do I do this transformation when the number
of variables to go into the nav array is unknown, and how do I generate the
index number? Can any experience mod_rewrite gurus point me in the right
direction. I'm sure this is a common design pattern.
Thanks. 3 2321
On Thu, 15 Feb 2007 00:15:34 +0100, Dr. No <no@no.nowrot e:
I am new to using mod_rewrite and am trying to rewrite a URL to pass
values to my script so that:
http://www.myclient.com/everything/animals/mammals/cats
is transformed into
http://www.myclient.com/index.php?nav[0]=everything&nav[1]=animals&nav[2]=mammals@nav[3]=cats
Specifically, I am looking for an n-ary solution to this problem. I know
how to do it for a discrete number, but how do I do this transformation
when the number of variables to go into the nav array is unknown, and
how do I generate the index number? Can any experience mod_rewrite gurus
point me in the right direction. I'm sure this is a common design
pattern.
As far as I know you cannot, not without really messy toying with
environmental variables.
As you're using PHP, what's wrong with:
RewriteEngine On
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d
RewriteRule ^(.*)$ index.php?nav=$ 1
And in PHP:
$nav = isset($_GET['nav']) ? explode('/',$_GET['nav']) : array();
--
Rik Wasmus
"Dr. No" <no@no.nowrot e in message
news:qK******** **********@news svr11.news.prod igy.net...
>I am new to using mod_rewrite and am trying to rewrite a URL to pass values to my script so that:
http://www.myclient.com/everything/animals/mammals/cats
is transformed into
http://www.myclient.com/index.php?nav[0]=everything&nav[1]=animals&nav[2]=mammals@nav[3]=cats
Specifically, I am looking for an n-ary solution to this problem. I know
how to do it for a discrete number, but how do I do this transformation
when the number of variables to go into the nav array is unknown, and how
do I generate the index number? Can any experience mod_rewrite gurus point
me in the right direction. I'm sure this is a common design pattern.
Just use empty brackets: nav[]=everything&nav[]=animals&nav[]=mammals, php
will understand this and create the index numbers for you.
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis sp**@outolempi. net | rot13(xv***@bhg byrzcv.arg)
Rik wrote:
As you're using PHP, what's wrong with:
RewriteEngine On
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d
RewriteRule ^(.*)$ index.php?nav=$ 1
And in PHP:
$nav = isset($_GET['nav']) ? explode('/',$_GET['nav']) : array();
Or even:
RewriteEngine On
RewriteCond %{REQUEST_FILEN AME} !-f
RewriteCond %{REQUEST_FILEN AME} !-d
RewriteRule ^(.*)$ index.php/$1
And in PHP:
$_GET['nav'] = explode('/',$_SERVER['PATH_INFO']);
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux
* = I'm getting there! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Westcoast Sheri |
last post by:
Hello. How do I do this:
If a visitor types in any number after my url, I want mod_rewrite to
convert it to my url/anotherpage.html?number=number_visitor_typed
Example:
http://www.mysite.com/12345678.html
would result in:
|
by: Support |
last post by:
Hello,
I am running RedHat & Apache. RedHat does not allow creating more
that 32000 subdirectories in one folder due to #defined constant
limitation in the core code.
I need to display 47000 directories on web page:
e.g. mydomain.com/andrew , mydomain.com/bill , etc. Each directory
contains .html/htm files and image files (*.jpg, *gif, jpeg etc.)
|
by: Shabam |
last post by:
In Apache there's a pretty powerful module called mod_rewrite. Is there
anything like that in dot net?
|
by: namemattersnot |
last post by:
ok. i give up. need help :)
here's the rule:
RewriteRule ^test/(.+)/(.*)$ /index.php$2
if i request: http://localhost/test/keyword/?show=files it properly
redirects me.
NOW, if i change the rule to: RewriteRule ^test/(.+)/(.*)$
|
by: joelbyrd |
last post by:
I have a people-networking type site in which each user has their own
profile page, with their user id encoded. So, for example, the web
address of their page might look like
"www.example.com/my_profile.php?user_id=fdjkhfh2489298hf298h3s0dhfxj".
I want the users to be able to choose their own web address that would
look like "www.example.com/Joel", and then when they type in that
address, they are automatically redirected to their profile...
| |
by: Hermann.Richter |
last post by:
I want to rewrite URLs like
http://domain/dir/file.php?var1=val1&var2=val2#anchor
to
http://domain/dir/file?var1=val1&var2=val2#anchor
In other words, I want to strip out the php extension
I tried putting in the .htaccess file the following:
|
by: laredotornado |
last post by:
Hi,
I have verified that mod_rewrite is enabled on my Apache 2.2 instance.
However, now I'm having a problem just serving pages using .htaccess
files. Following Rik's advice, my .htaccess file is as follows
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !^accesscontrol.php
|
by: cheesecaker |
last post by:
Hi, I need a specific redirect out of mod_rewrite, and I've never done regex a day in my life. Understandably, this makes things difficult. Been trying for hours, now I give up trying to slave it out myself.
What I need is the following: Any and all requests should be redirected to the GET of a PHP file that will handle some redirection. I know the PHP file is fine, now I need to get the RewriteRule working. Here's what I have so far:
...
|
by: Dale |
last post by:
again, i know this is OT...just move along to the next post if it bugs you.
:)
i had been trying to have this:
project.66.204.32.110
from the client browser, map to a virtual host where the document root would
be:
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |