MasterKaos
Programmer
We are developing a PHP framework which will feature SEF urls. The requirement is that mod rewrite will convert url elements into GET vars. We want to keep this nice and arbitrary for easy re-factoring.
Here's the idea:
=
So each word between slashes, after the first, will populate PHP’s $_GET array with a numerically indexed array of parameters. The number of possible parameters needs to be arbitrary. Furthermore, after the SEF style of parameters, traditional get query strings can also be used, e.g.:
Currently we have a mod rewrite condition for each level of the url. e.g.:
I’m sure there must be a better way to do this, to write a single condition / rule which will support urls n levels deep.
Being a mod rewrite noob I have not been able to work out a way to do this.
Any suggestions?
Cheers!
----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
Here's the idea:
=
So each word between slashes, after the first, will populate PHP’s $_GET array with a numerically indexed array of parameters. The number of possible parameters needs to be arbitrary. Furthermore, after the SEF style of parameters, traditional get query strings can also be used, e.g.:
Currently we have a mod rewrite condition for each level of the url. e.g.:
Code:
RewriteRule index.php - [L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/javascript
RewriteRule ^(.[^/]*)[/]?$ /index.php?class=$1 [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/javascript
RewriteRule ^(.[^/]*)/(.[^/]*)[/]?$ /index.php?class=$1&0=$2 [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/javascript
RewriteRule ^(.[^/]*)/(.[^/]*)/(.[^/]*)[/]?$ /index.php?class=$1&0=$2&1=$3 [L,QSA]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/javascript
RewriteRule ^(.[^/]*)/(.[^/]*)/(.[^/]*)/(.[^/]*)[/]?$ /index.php?class=$1&0=$2&1=$3&2=$4 [L,QSA]
Being a mod rewrite noob I have not been able to work out a way to do this.
Any suggestions?
Cheers!
----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.