Solved:
unfortunately, the solution is not a satisfying one. This morning, when trying @Wige's Suggestion, I found, to my suprise, that the Expected values WERE infact sent to the page as a GET
query. Apparently, 1&1 (who I know have been making changes to their environment this last couple weeks), did something behind the scenes which magically fixed my problem, and now all of my previously unworking code is working as originally expected.
New info: The Apache version of the production server is 1.3.34
vs 2.2.21
on my localhost.
I'm having trouble figuring out why my RewriteRule is not working properly in production.
RewriteRule ^page/pretty-url/(.*)$ page.php?query=$1 [L]
In my local testing environment (localhost/mysite/page/pretty-url/{...}
) it works fine, but on mysite.com/page/pretty-url/{...}
it doesn't work properly. It loads page.php
as expected but apparently the ?query=$1
piece is ignored ($_GET
is empty)
I imagine that the problem is somehow related to the server configuration. I'm on a 1&1 shared hosting account with no httpd.conf access.
What that RewriteRule
does (or should do):
I want urls like
*
example.com/page/pretty-url/{{info_for_dynamic_content}}
to be rewritten to
*
/page.php?query={{info_for_dynamic_content}}
So I can access info_for_dynamic_content
within php
as $_GET['query']
The full .htaccess file for reference:
AddHandler x-mapp-php6 .php
DirectoryIndex index.php
ErrorDocument 404 /index.php
Options +FollowSymLinks
# per @Jacques Chester's suggestion
Options -MultiViews
RewriteEngine on
RewriteBase /
# the rule in question
RewriteRule ^page/pretty-url/(.*)$ page.php?query=$1 [L]
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php !-f
RewriteRule (.*) /index.php [L]