I have the following logic in my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule notes/(.*?) notes/?u=/$1
</IfModule>
However, for some reason this always removes the query string from the output. So, this is for example the result I git:
http://localhost:8888/notes/tifffilmtips > http://localhost/notes/
However, if I change the RewriteRule to RewriteRule notes/(.*?) notes/u=/$1
, excluding the ?
before the u=
, the result is:
http://localhost:8888/notes/tifffilmtips > http://localhost/notes/u=/tifffilmtips
So for some reason, the output always discards the generated query string. Why would this be? I’ve tried different flags, but I can’t find one that works as expected, and I can’t find reference to other people having similar problems.
EDIT:
Here’s the complete htaccess with the first part working:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteBase /magazine/wordpress/
RewriteRule ^notes/(.*)$ notes/?u=/$1 [QSA,NC,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /magazine/wordpress/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /magazine/wordpress/index.php [L]
</IfModule>
# END WordPress
Change your RewriteRule to this:
If
/notes/
is being routed as a wordpress permalink, then this is going to be a bit painful as wordpress usually strips out the query string when you turn on permalinks. Take a look at this post which goes over why wordpress is doing this, how it’s doing it, and how to work around it. Permalinks in wordpress adds an additional layer of rewriting that’s internal to wordpress and query string parameters get blown away when that happens. So the fix involves adding some php code, specifically in your theme’sfunctions.php
script. Something like:then: