Support » Fixing WordPress » .htaccess mod_rewrite help

  • Resolved gh3

    (@gh3)


    Hi, i got a trouble.

    I use WP 2.0.4, actually my .htacess is the one generated as default by Wp

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    I wanted to add a new rule like:

    if i point on http://domain/profile/username.htm the system will turn in to
    http://domain/index.php?user=username

    I’ve write this rule:

    RewriteRule ^/profie/(.*).htm$ index.php?user=$1 [L]

    So my new .htaccess looked like this:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^/profie/(.*).htm$ index.php?user=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    But if i browse http://domain/profile/username.htm, i always reach a 404 page made by WP.

    Any idea or suggestion to fix this?

    Thanks in advance.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You misspelled “profile” in your rule. Also you should escape the dot.

    RewriteRule ^/profile/(.*)\.htm$ index.php?user=$1 [L]

    i’ve fixed the mispelled and dot but it still redirect me to the 404 error of the theme

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Hmmm.. Change the [L] to [R,L] and see if that works.

    no, it seems to love 404 page 🙁

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    gh3: Does the actual index.php?user=whatever page work if you use it directly?

    there’s no way to get it work, but the wp rule works and anti hotlink of images works too 🙁

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Well, I gotta say that I don’t know what you’re doing wrong, but that rule above is correct and will work. So I’d look at something else. Maybe your server config is bad. Dunno.

    solved 🙂

    you have to add in functions.php of the theme a rule like:

    function foo_bar_rewrite_rules($rules) {
    global $wp_rewrite;
    $newrules[‘cerca.htm$’] = ‘index.php?cerca’;
    $newrules[‘profilo/(.+).htm$’] = ‘index.php?user=$matches[1]’;
    return array_merge($newrules,$rules);
    }
    add_filter(‘rewrite_rules_array’,’foo_bar_rewrite_rules’);

    update_option(‘rewrite_rules’, ”);

    😀

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘.htaccess mod_rewrite help’ is closed to new replies.