Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple MVC mod-rewrite
    primarykey
    data
    text
    <p>I'm not sure how to do a mod-rewrite for a modular MVC structure. What I want to happen is the URL captures:</p> <p><code><a href="http://domainname.com/index.php?model=" rel="nofollow noreferrer">http://domainname.com/index.php?model=</a>{model}&amp;view={view}&amp;parameters={parameters}</code><br /><br /> <em>NOTE: parameters will be in a specific order and separated by pipes (unless there is a better way): parameters=param1|param2|param3</em><br /><br /> <code><a href="http://domainname.com/" rel="nofollow noreferrer">http://domainname.com/</a>{model}/{view}/{parameters}</code></p> <p>Example:</p> <p><code><a href="http://domainname.com/faq/edit/13" rel="nofollow noreferrer">http://domainname.com/faq/edit/13</a></code></p> <p>Another Example:</p> <p><code><a href="http://domainname.com/faq/index/" rel="nofollow noreferrer">http://domainname.com/faq/index/</a>{sort}/{page}/{search}</code> <code><a href="http://domainname.com/faq/index/asc/3/How+to" rel="nofollow noreferrer">http://domainname.com/faq/index/asc/3/How+to</a></code></p> <p>Essentially anything after the model and view will and can be parameters; as many as needed. For each view I will know the possible parameters that area allowable and in what order.</p> <p>Thank you in advance.</p> <p>--</p> <p>Using the code below this is what I have:<br /><br /></p> <pre> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/(.*)/(.*) index.php?model=$1&view=$2&parameters=$3 [L,NS] </pre> <p>URL: <code><a href="http://localhost:8888/testing/faq/index/asc/5/How+to" rel="nofollow noreferrer">http://localhost:8888/testing/faq/index/asc/5/How+to</a></code><br /> PHP $_GET variables:</p> <pre> Array ( [model] => faq/index/asc [view] => 5 [parameters] => How to ) </pre> <p>Should be:</p> <pre> Array ( [model] => faq [view] => index [parameters] => asc/5/How to ) </pre> <p>Please help</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload