mR.aTA
mR.aTA

Reputation: 314

rewrite rule my urls in wordpress

i search a lot in the web and read many tuts and references but could not solve my problem! here is my problem: in my wordpress site i have some urls like this:

localhost/mysite/articles/?arc=8892

i have this url because in my php code i validate that article:

<?php 
    $article = wp_getpost($_GET['arc']); //arc = 8892
    if($article->post_type == 'article')
    //process article....

which 8892 is id of a post with article custom post type! also i have a plugin names custom post type permalink which set this style for this post type. what i wanna do is rewrite below url to current urls:

localhost/mysite/article/8892

without any change in my php code. in my htaccess code i have this but does not work:

RewriteRule ^articles/?([0-9]+)/?$ /articles/?arc=$1 [NC]

Upvotes: 1

Views: 28

Answers (1)

Mohammad Jafar Mashhadi
Mohammad Jafar Mashhadi

Reputation: 4251

You don't have to write .htaccess manually, wordpress does it for you.

Just go to http://path/to/your/blog/wp-admin/options-permalink.php in yout browser and use one of the predefined url strucutres or write a custom one yourself.

Screenshot

Upvotes: 1

Related Questions