Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

Here is what I am using:

RewriteCond %{HTTP_HOST} ^example\.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 file (in WP root). I am running WordPress 3.1.3 multisite (subdomains), WP MU Domain Mapping plugin, and buddypress on example.com. The mapped domain name is example.com, not the actual subdomain.

I was assuming that my rewrite rule would load example.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).

share|improve this question
add comment

1 Answer

not sure if this is a problem for you still or not, but if so I noticed a few issues. First off, your domain wasn't set to be case-insensitive [NC]. Second, your RewriteRule regex has a character class ending with a dash. This needs to start with a dash. Third, your rule sends the request to index.php, which means index.php needs to know how to handle the request. If you want to redirect, that's different. Give this a whirl and let me know how you make out:

RewriteCond %{HTTP_HOST} ^domainXYZ\.com [NC]
RewriteCond %{REQUEST_FILENAME} !wp-admin
RewriteCond %{REQUEST_FILENAME} !activity
RewriteCond %{REQUEST_FILENAME} !members
RewriteCond %{REQUEST_FILENAME} !groups
RewriteRule ^([^/]+)/?$ http://domainXYZ\.com [L,R=301]

Cheers~

share|improve this answer
    
Thanks for the reply! I always appreciate input from folks are good with regex and rewrite rules. Not my strongest suit. However, I ended up writing the redirection into a WP template hook instead of using a rewrite rule. add_action('template_redirect', 'my_function'); –  user568428 Jan 31 '12 at 5:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.