Hello,
I hope I may ask some mod rewrite realted help.

I would like to make my blog URLs of the type:

http://www.myblog.com/blog/?author_name=USER_NAME_HERE/

into easier to remember and easier to type URLs such as:

http://www.myblog.com/blog/USER_NAME_HERE/

so that when a visitor types in the latter he is redirected to the former.

I have tried this but it doesn't work:
Redirect /blog/(.)$ http://www.myblog.com/blog/?author_name=%1 [R=301,L]
and this:
RewriteRule /blog/(.)
ยป /blog/?author_name=$1

    Although that seems to be only a + away from what I have tried it doesn't work... I get a "not found" error, as if it is looking for that file/folder specifically...

      marcnyc wrote:

      Although that seems to be only a + away from what I have tried it doesn't work... I get a "not found" error, as if it is looking for that file/folder specifically...

      Odd, works fine for me...

      Did you change the blog/(.+)/$ so that it finds the blog folder relative to the current directory?

      Cheers,

      Ryan Jones

        OK how about thiis:

        RewriteEngine on 
        RewriteRule ^blog/([a-zA-Z0-9_]+)/$ http://www.myblog.com/blog/?author_name=$1 [R=301,L]

        The exctcode I now haveon the test page:

        RewriteEngine on 
        RewriteRule ^blog/([a-zA-Z0-9_]+)/$ http://www.standards.spiralmindsinc.com/Testing/PHPBuilder/Marcnyc10318239/index.php?author_name=$1 [R=301,L]

        Just remember, make shure you get the relative directories correct ๐Ÿ™‚

        Cheers,

        Ryan Jones

          that ALMOST workd ;-)
          I was getting a 404 error until I removed the last slash after the regex, so the working code I found to be this:

          RewriteEngine on
          RewriteRule ^blog/([a-zA-Z0-9_]+)$ http://www.myblog/blog/index.php?author_name=$1 [R=301,L]

          Thanks for your help, I really appreciate your time...
          Now my only doubt is, why would (.+) not work and ([a-zA-Z0-9_]+) did?

            Write a Reply...