Home htaccess wordpress rewriterule not working 404 error
Reply: 0

htaccess wordpress rewriterule not working 404 error

user1534
1#
user1534 Published in July 21, 2018, 9:55 am

I'm attempting to make a rewriterule for a page to load the content of another one and show the proper information.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^index\.php/file/(.*)$ index.php/file/?value=$1 [L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

When i put my url it shows me a 404 error but the "index.php/file/?value=$1" is working fine for me.

Any help?

EDIT:

Still not working... I've been dealing with this issue for almost a week so if someone knows how to make this work please tell me.

EDIT 2 [SOLUTION]:

I finally get to solve my problem. The point is that I needed to make some changes into my functions.php file from the wp theme:

add_filter('query_vars', 'add_state_var', 0, 1);
function add_state_var($vars){
    $vars[] = 'value';
    return $vars;
}

add_rewrite_rule('^file/([^/]+)/?$','index.php?
pagename=file&value=$matches[1]','top');

and leave my .htaccess file like:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Hope this could help somebody!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.395768 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO