简体   繁体   中英

Using $_POST data after wordpress url rewrite

My permalink structure is set so I have url.com/page

I made a basic PHP script prior to installing wordpress that uses $_POST data to display the correct set of information, so the base would look like url.com/work.php?featured=print

After adding this to my Wordpress installation with the rewrite from the permalink structure above, the link actually works as: url.com/work/?featured=print

I'm having trouble getting the extra rewrite to work so that a clean url.com/work/print will work properly.

This is what my .htaccess file looks like, I appended the last line before the end IfModule tag hoping that would take anything work/[page]/ and direct it to work/?featured=[page]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
RewriteRule ^work/([^/.]+)/?$ work/?featured=$1 [L]
</IfModule>
# END WordPress

any help?

EDIT

Discovered rewrite via the functions page and found this quite resourceful

Rewrite rules for WordPress

however, my rule is taking .com/work/print (work/?feat=print) and simply showing it as .com/work without the page data being passed through

'work/([^/]+)/?$' => 'work&feat=$matches[1]'

The above is the only thing I changed from post I just referenced. I tried keeping is specific to get it to work first to avoid any loose ends... Still not working properly though

The wp-admin dashboard has a tool that helps with the rewrites. When I ran a few WP sites, I used it to achieve what I wanted. Did you try that first?

http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/

For some reason, couldn't get anything to work, but ^ is quite simple and worked great

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM