Welcome Guest, Not a member yet? Register   Sign In
So close with a mod_rewrite that changes underscores to hyphens for SEO. Can anyone close it out?
#13

[eluser]InsiteFX[/eluser]
I know you have solved this but here is the Apache .htacces way of doing it!

The Apache .htaccess underscore to hyphen conversion code
Code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /

RewriteRule !\.(html|php)$ - [S=6]
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]

RewriteCond %{ENV:underscores} ^Yes$
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

InsiteFX


Messages In This Thread
So close with a mod_rewrite that changes underscores to hyphens for SEO. Can anyone close it out? - by El Forum - 03-22-2011, 03:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB