Forums

mod_rewrite expertise needed (2 posts)

  1. meeble
    Member
    Posted 6 months ago #

    Hello,

    I am trying to modify my WordPress .htaccess file and customize the mod_rewrite directives to allow for more complex URLs and passing variables to PHP while maintaining WordPress "pretty permalink" functionality.

    Something like this:

    http://mydomain.com/hello-world

    (would work like WP does by default with pretty permalinks enabled)

    http://mydomain.com/varA/hello-world

    (would trick WP into displaying the same "hello-world" post as above, but also would pass the "varA" string to PHP as a variable)

    http://mydomain.com/varA/varB/hello-world

    (would again trick WP into displaying the same "hello-world" post as above, but also would pass the "varA" and "varB" strings to PHP as variables)

    to further clarify, the mod_rewrite code would be outputting something like this:

    index.php?varA=$1&varB=$2

    in which case I could easily grab those variables in php using:
    $a = $_GET['varA'];
    $b = $_GET['varB'];

    Lastly, the new mod_rewrite directives would still need to handle WordPress categories and tags which come in the form of:

    http://mydomain.com/category/category1
    http://mydomain,com/tag/sometag

    BTW, the default WordPress mod_rewrite directives in my .htaccess file are:

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

    Thanks,
    Devin

  2. meeble
    Member
    Posted 6 months ago #

    Please disregard this post.

    This is an updated and more specific post about this issue:

    http://wordpress.org/support/topic/modifying-wp-url-handing-code

Reply

You must log in to post.

About this Topic