Note that there are some explanatory texts on larger screens.

plurals
  1. POMod rewrite rule to append query string and continue
    text
    copied!<p>Not sure if there's a reasonable way to do this or if maybe I'm missing something. I have a content management system that I've build that passes everything through a template system (which is essentially a single PHP file that does the processing). With that in mind, the following rules will send requests to lucy.php where the url is validated and the appropriate template loaded.</p> <pre><code>RewriteRule ^$ lucy.php [L,QSA] RewriteRule ^([^/\.]+)/?$ lucy.php?section1=$1 [L,QSA] RewriteRule ^([^/\.]+)/([^/\.]+)/?$ lucy.php?section1=$1&amp;section2=$2 [L,QSA] RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ lucy.php?section1=$1&amp;section2=$2&amp;section3=$3 [L,QSA] </code></pre> <p>So each part of the URL is sent as a section# variable to the script. My issue is when I'm using a template that requires its own URL system. In this case... a blog. Normally, I would do something like</p> <pre><code>RewriteRule ^blog/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/\.]+)/?$ site/blog.php?year=$1&amp;month=$2&amp;day=$3&amp;blog_url=$4 [L,QSA] </code></pre> <p>to send the request to a one off script. The way I'm doing it now is that <a href="http://domain.com/blog" rel="nofollow">http://domain.com/blog</a> will still go through the aforementioned lucy.php script where a blog template is loaded and displayed. So, is it possible to continue allowing the /blog portion of the request to be routed to the appropriate rewrite rule but to also append the year, month, day, and blog_url fields to the query string? The /blog url will not consistently be the same and may not even be called blog, so I need something that will work dynamically. </p> <p>The only idea I had was to duplicate each instance of the lucy.php rewrites to include optional parameters for date based structures. Something like...</p> <pre><code>RewriteRule ^([^/\.]+)/([0-9]{4})/([0-9]{2})/([0-9]{2})/([^/\.]+)/?$ lucy.php?section1=$1&amp;year=$2&amp;month=$3&amp;day=$4&amp;item_url=$5 [L,QSA] </code></pre> <p>But I thought there might be more efficient way of doing it. The other issue with that convention is that I'd like this to work for other scenarios like category, author, and other non-blog scenarios. I don't want to have to duplicate the block of lucy.php rewrites for every one of these instances. Thoughts?</p>
 

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