WordPress / mod_rewrite expert needed
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: WordPress / mod_rewrite expert needed

  1. #1
    Join Date
    Nov 2011

    Question WordPress / mod_rewrite expert needed


    I am looking for someone who can help me 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:


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


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


    (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:


    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 have to handle WordPress categories and tags which come in the form of:


    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]

    Let me know if you think you can achieve this!


  2. #2
    Join Date
    Nov 2011

    Question Re: WordPress / mod_rewrite expert needed

    Further clarification:

    I need a WordPress developer - the modifications should be done using best WordPress methods, to facilitate easy upgrading i.e. using WordPress API hooks/filters/etc. as opposed to rough PHP code. I am using WP 3.2.1. Here's what I have tried so far:

    I added the following mod_rewrite code to my .htaccess file:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(\w+)/(\w+)/ /index.php?st=$1&city=$2 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(\w+)/ /index.php?st=$1 [L]

    which kind of works. The variables are being passed, and PHP can grab them with:
    $state = $_GET['st'];
    $city = $_GET['city'];

    The problem is that WP is getting confused by the URL and isn't finding the post. URL's like these:


    are bringing up a page not found error. Also, when entering this URL:


    It redirects to: http:/epiclasers.com/hello-world
    which then displays the post fine.

    We need to modify the WP URL handling code to ignore the /state and /city parts of the URL without breaking URLs like:



Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This a Codeguru.com survey!

On-Demand Webinars (sponsored)