WordPress.org

Ready to get started?Download WordPress

Forums

How to modify .htaccess for web app (in combination with WordPress) (3 posts)

  1. dxjones
    Member
    Posted 3 years ago #

    I am using WordPress 3.0.1 as the front end for my web application.
    I have most of it working, but I need some help customizing ".htaccess"

    Here is what works:

    1. I use Exec-PHP plugin to run my embedded PHP code inside a WordPress "Page" called "app".
    2. I use pretty Permalinks for good SEO. This URL = "http://site.com/app/" displays the correct page and runs my code.
    3. To pass parameters to my app, this URL = "http://site.com/app/?a=alpha&b=beta" also displays the correct page, and my PHP code can see the parameters in $_GET['a'] and $_GET['b'].

    Here is where I need help with ".htaccess"

    I want this URL = "http://site.com/app/alpha/beta" to be rewritten using the Apache2 mod_rewrite engine to become "http://site.com/app/?a=alpha&b=beta" and then display the correct page (like item 3) above.

    I have tried adding various things in ".htaccess", but I can't get it to work. I typically end up with a WordPress 404 page being displayed.

    Here is the .htaccess file created when installing WordPress 3.0.1.

    [code]
    # .htaccess
    # 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
    [/code]

    I am sure there must be lots of folks using WordPress as a front end for their web app, and others with expertise in .htaccess syntax. Any answers or pointers to solutions would be much appreciated.

    thanks in advance,

    David Jones
    dxjones@gmail.com
    http://dxjones.com

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 3 years ago #

    This might work. Put it before the WP rules, outside their block.

    RewriteEngine On
    RewriteRule ^app/([^/]+)/([^/]+)$ /app/?a=$1&b=$2 [QSA]
  3. dxjones
    Member
    Posted 3 years ago #

    Thanks for the suggestion.

    I tried that, but it didn't work for me.

    I always get a WordPress page saying:

    Error 404 - Page Not Found!
    Whoops! Something broke. Please try again!

    Here is the current content of my .htaccess (my "app" is called "keyword")

    # .htaccess

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^keyword/([^/]+)/([^/]+)$ /keyword/?a=$1&b=$2 [QSA]
    RewriteRule ^keyword/([^/]+)$ /keyword/?a=$1 [QSA]
    </IfModule>

    # 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 am still looking for a solution, ...

Topic Closed

This topic has been closed to new replies.

About this Topic