mod_rewrite help
Posted by: kqf3143
Posted on: 2007-06-03 10:17:00
I'm a complete noob when it comes to mod_rewrite, and I could really use some help. I'm in the process of migrating my site from ExpressionEngine to WordPress, and would like to have as many inbound links to the old site continue to function in the new version. The basic structure of the EE urls is:
http://www.mysite.net/index.php?/weblog/post_name
The basic structure of the WP urls will be:
http://www.mysite.net/post-name
So what I need to do is use mod_rewrite to remove the "index.php?/weblog/" string, and to replace underscores with hyphens. I've searched around and read everything I can find, and can't get anything to work at all. Right now, my .htaccess file reads:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats|failed_auth.html)/?(.*)$ [NC]
RewriteRule ^.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This works mostly fine; anything with the "index.php?/weblog/" string is redirected to index.php. But if I add this above the WordPress info:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/index.php?/weblog/(.*)$ http://www.mysite.net/$1 [R=301,L]
</IfModule>
nothing changes -- URI requests that include the "index.php?/weblog" string still redirect to the front page.
Similarly, adding something like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5-$6-$7 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5-$6 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4-$5 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_([^_]*)_(.*)$ $1-$2-$3-$4 [E=underscores:Yes]
RewriteRule ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3 [E=underscores:Yes]
RewriteRule ^([^_]*)_(.*)$ $1-$2 [E=underscores:Yes]
</IfModule>
has no effect whatsoever on the underscore/hyphen issue.
Any help would be really, really appreciated. I'm far out beyond the edge of my envelope here. Thanks!