SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wordpress WP-Rewrite ????

    I created a wordpress plug-in that takes some variables from the URL, and I would like the URL to be rewritten to be more user friendly.

    So: www.example.com/var/value
    Would be rewritten to: www.example.com/?var=value

    I could do this with mod_rewrite with ONE LINE and in 1 MINUTE.

    However it seems that the newer versions of WP do not use the .htaccess to rewrite the URL. Instead everything is rewritten to index.php and is handled internally.

    I tried to find out how to do what I want with WP but with no luck. The documentation gives an example http://codex.wordpress.org/Function_...ewrite#Example which DOESN'T WORK, and searching the wordpress forums I found 10s of requests about this issue with NO ANSWER.

    So has Wordpress made a perfectly easy and simple thing overly difficult and impossible to implement by anybody who is not a Wordpress Guru?

  2. #2
    Word Painter silver trophy Shyflower's Avatar
    Join Date
    Oct 2003
    Location
    Winona, MN USA
    Posts
    10,053
    Mentioned
    142 Post(s)
    Tagged
    2 Thread(s)
    I'm not a programmer so this may not help you or even be what you are looking for.

    I use what WP calls custom permalinks to make user friendly urls.
    Code:
    /%category%/%postname%/
    the post slug in the admin sidebar is my 'post-name' so the pages resolve to:

    mydomain/category/post-slug.

    In the WP dashboard, you find the custom permalinks under options.

    If that isn't what you want, how does it differ?
    Linda Jenkinson
    "Say what you mean. Mean what you say. But don't say it mean." ~Unknown

  3. #3
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Shyflower but what I am looking for is a bit different.

    I am not referring to the standard functionality of WP but about URL rewriting for plugins.

  4. #4
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been wondering the same thing actually. I assumed it would all be there in the .htaccess file, but when I looked ... it was empty!

    The latest version of WordPress does some funky stuff with URL canonicalisation so I'm assuming that has something to do with the reason for no using .htaccess.

  5. #5
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I managed to find out. What would otherwise be one line rule in .htaccess it now takes 3 wp functions!! The info is here:
    http://codex.wordpress.org/Custom_Queries

    You need to 1) tell WP what variables you are expecting from the query, 2) "flush" the cached rewrite rules and 3) add your new rules.

  6. #6
    SitePoint Wizard ryanhellyer's Avatar
    Join Date
    Oct 2006
    Location
    New Zealand
    Posts
    2,323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you find out why they do it that way?

  7. #7
    SitePoint Addict
    Join Date
    Aug 2006
    Posts
    288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know. I guess they decided this was a more slick way to handle it. Maybe it has some other advantages also, and I hope it does since it does make things more difficult, especially until you figure out what you have to do.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •