Forums

Need help with simple rewrite rule (should't this be easy?) (8 posts)

  1. agentOOjoe
    Member
    Posted 11 months ago #

    All I need is a rewrite that will change "domainXYZ.com/anyphrase" into "domainXYZ.com"

    Here is what I am using:

    RewriteCond %{HTTP_HOST} ^domainXYZ\.com
    RewriteCond %{SCRIPT_FILENAME} !wp-admin
    RewriteCond %{SCRIPT_FILENAME} !activity
    RewriteCond %{SCRIPT_FILENAME} !members
    RewriteCond %{SCRIPT_FILENAME} !groups
    RewriteRule ^([A-Za-z0-9-]+)/?$ index.php [L]

    Notes: I added the above to the top of my .htaccess (in WP root). I am running WP 3.1.3 multisite (subdomains), WP MU Domain Mapping plugin, and buddypress on domainXYZ.com. domainXYZ.com is the mapped domain name, not the actual subdomain.

    I was assuming that my rewrite rule would load domainXYZ.com/index.php, which would load the homepage for the wordpress site. However, I get a "page not found" response shown in my buddypress skin (not a full-blown error 404 page).

    Thanks to anyone who can help, Joe

  2. Andrea_r
    team pirate
    Posted 11 months ago #

    So you're running buddypress on the mapped domain, which is a secondary blog in the network? Correct?

    If so.. why the rewrite rules? shouldn't need 'em at all.

    First try turning off BP and ensure the mapped domain works. Then check you specific in the config file that BP's root blog is not the main site in the network.

  3. agentOOjoe
    Member
    Posted 11 months ago #

    Hey Andrea, I've read quite a few of your posts around this site, particularly those pertaining to buddypress and domain mapping. Thanks for your help.

    So you're running buddypress on the mapped domain, which is a secondary blog in the network? Correct?

    -Exactly correct

    First try turning off BP and ensure the mapped domain works. Then check you specific in the config file that BP's root blog is not the main site in the network.

    -I just disabled buddypress, and applied the Twenty-Ten theme to test the mapping. Mapping is working well. However, the mod_rewrite still wont work. It still behaves just like any theme would giving me the "page not found" when you type in mysite.com/not-an-actual-folder-or-page.
    -I double checked my BP root blog setting. It is correct.

    I was wondering, could there be a confliction with the file bp-core-catchuri.php?

  4. Andrea_r
    team pirate
    Posted 11 months ago #

    Ipstenu is the htaccess goddess - is what you're trying to do this?

    redirect any 404 to the mapped domain and not the theme's 404 page

  5. agentOOjoe
    Member
    Posted 11 months ago #

    Well, I was thinking that could be one approach, but it seemed a bit messy. Do you know if this would affect SEO at all? Would it be throwing 404 errors still?

  6. agentOOjoe
    Member
    Posted 11 months ago #

    Solution:
    The rewrite task was killing me, so I just changed the way WP dealt with a 404.

    Unfortunately, I had to alter some WP core files, but the functions I changed were:

    set_404(); (this allowed me to communicate to my theme that certain 404's should instead load the home template)

    and

    status_header(); (to stop from sending the 404 header when a specific type of nonexistent url is entered)

  7. Ron Rennick
    MultiSite Guru
    Posted 11 months ago #

    Change your last line to

    RewriteRule ^([A-Za-z0-9-]+)/?$ http://domainXYZ.com [L]

    Except a request for a physical file, every request is redirected to index.php.

  8. agentOOjoe
    Member
    Posted 11 months ago #

    Thanks Ron,
    The only problem with that rule is that when I use an absolute address it acts more like a redirect (address bar gets reset to domainXYZ.com). I need the address bar to read domainXYZ.com/keyword so that I can extract the keyword using $_SERVER['REQUEST_URI'] and apply the variable to my application.

Reply

You must log in to post.

About this Topic