Monday 15 April 2013

php - Change GET vars to url path in Wordpress -



php - Change GET vars to url path in Wordpress -

i want rewrite rule able alter variable nicer url.

for example:

example.com?category=news to: example.com/category/news

i want other variables left alone.

example:

example.com?category=news&sort=asc to: example.com/category/news&sort=asc

the modifications need take place in wordpress htaccess file:

# 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 don't want redirect, want url to change.

update 1

i tried jon lin's example. worked, i'd add together /en before , i'd category varaible.

i tried mod rewrite generator, got result, doesn't work.

rewriteengine on rewriterule ^category/([^/]*)$ /en/?category=$1 [l]

next tried combine two, i'm not closer figuring out problem is.

rewriteengine on rewritecond %{the_request} \ /(index\.php)?\?/en/category=$1&?([^\ ]*) rewriterule ^ /en/category/%1?%2 [l,r] rewriterule ^category/([^/]*)$ /en/?category=$1 [l,qsa] # 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

try adding these rules before wordpress rules:

rewriteengine on rewritecond %{the_request} \ /(index\.php)?\?category=news&?([^\ ]*) rewriterule ^ /category/news?%2 [l,r] rewriterule ^category/news$ /?category=news [l,qsa]

php wordpress .htaccess

No comments:

Post a Comment