I am using wordpress, i have some URL issue.
My current URL is IP address on server: http://www.192.10.1.22/states/?q=ohio
I want URL :http://www.192.10.1.22/states/ohio
i used following code in functions.php file and it’s working in my
local but when i upload in cpanel then it’s now working given me error
page not found.
function custom_rewrite_rule() {
add_rewrite_rule(
'states/([^/]*)/?',
'index.php/states/?q=$1',
'top' );
}
add_action('init', 'custom_rewrite_rule', 10, 0);
i also used below code.
add_rewrite_tag('%states%', '([^&]+)');
global $wp;
$wp->add_query_var( 'q' );
add_rewrite_rule(
'states/(d*)$',
'index.php/states?q=$matches[1]',
'top'
);
i also update permalink and apache mode_rewrite is also on.
so how could i solve this issue?
2
Answers
You can directly add the rule in your .htaccess file on server.