Jump to content

Featured Replies

Posted

Moving the site from 'forums' folder to root folder. Can anyone help with htaccess 301 redirect, so old index content by google doesn't get mess up? Thank you. 

This is the current htaccess:

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map|webp)(\?|$) /404error.php [L,NC]

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

 

  • Community Expert

Try something like:

RewriteRule ^/forums/(.*)$ /$1 [L,NC,R=302]

But that will only work if forums is not in the new path as well. 

Edited by Randy Calvert

  • Community Expert

Try that rule without the first slash BUT right after the rewrite engine on directive. I think you’re hitting an order of operations issue. 

  • Author
4 minutes ago, Randy Calvert said:

Try that rule without the first slash BUT right after the rewrite engine on directive. I think you’re hitting an order of operations issue. 

Sorry, I don't want to screw up.. so checking. Something like this?

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map|webp)(\?|$) /404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^forums/(.*)$ /$1 [L,NC,R=302]
RewriteRule . /index.php [L]
</IfModule>

 

  • Community Expert

Move it after 

RewriteEngine On
  • Author

Thanks! This worked.  Appreciate your help.

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^forums/(.*)$ /$1 [L,NC,R=302]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map|webp)(\?|$) /404error.php [L,NC]

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

 

  • Community Expert

Just to explain what was going on with the rule, it had to be moved up in the order of operations before later matches routed the request to index.php. The L directive said stop processing rules and just submit as is. The subsequent request with the folder removed then matched the call to index.php. 

Recently Browsing 0

  • No registered users viewing this page.