• Resolved ilen

    (@ilen)


    Is there some WP secret sauce that’s involved in using .htaccess for url rewriting? Am I editing the wrong file?

    I’m pointing my old coldfusion site at my shiny new wordpress instance and I want to handle old links gracefully.

    Based on my (admittedly limited) understanding of mod_rewrite. I would expect that going to:

    https://mydoman.com/validwppage.cfm

    would take me to:

    https://mydomain.com/validwppage/

    But instead I just get a WP 404 error when I use the rules below.

    # For rewrite rules needed for making WordPress URL friendly
    # See Options -> Permalinks for details and please use the defaults,
    # especially in mind when hosting several blogs on one machine!
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    # remove .cfm extension and add trailing slash
    RewriteRule ^(.*)\.cfm$ $1/
    # WordPress stuff below this
    
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule  ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    
    </IfModule>
    
    # END WordPress

    .htaccess file is in my site’s root directory (/var/www)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Change this:

    # remove .cfm extension and add trailing slash
    RewriteRule ^(.*)\.cfm$ $1/

    to

    # remove .cfm extension and add trailing slash
    RewriteRule ^(.*)\.cfm$ https://domain.com/$1 [R=301,L]

    Sometimes it gets daft.

    Thread Starter ilen

    (@ilen)

    THANK YOU!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘.htaccess not working… what am I doing wrong.’ is closed to new replies.