So this is my htaccess file as WordPress supplies it
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I have a page at /events, that I want to add a block of text via a template PHP file, depending on if a URL parameter exists.
So I took a look online, and tried to write an .htaccess rule for it. What I came up with was this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^events/([^/.]+)/?$ events/?flow=$1 [L]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
However, I don’t think this is working how I’d like it to. The link from the original page is /events?flow=open-evenings and in the events page, I have the usual $_GET thing:
$flow = isset($_GET['flow']) ? $_GET['flow'] : '';
if($flow == 'open-evenings') { echo "blah"; }
But when I try to view the URL /events/open-evenings I get the 404 error page. Have I placed the rule in the wrong place, or am I not doing something obvious? All help is appreciated!
Update: this is using WordPress, so maybe i shouldn’t be using the already rewritten urls? Should I be using index.php instead? But will that still pickup the pretty urls that I’m trying to use?
I’ve tried to change the URL to index.php, to try and get that to work, but with the below rule, I’m still getting a 404 page.
RewriteRule ^events/([^/]*)$ /index.php?flow=$1
Can anyone help me try to get this working?
This will do the following:
to be like
You can use these rules in root .htaccess:
Let me know if that helps…
Replace the needed values to yours. Is this something similar that you need?