Skip to main content
Inspiring
August 6, 2019
Question

htaccess & 301 redirect

  • August 6, 2019
  • 2 replies
  • 1526 views

Example of code in the .htaccess file below. Not sure why it is not working. Should those old files be purged from the server, or does it not matter? I did purge one of them during my testing, but did not make a difference. I get the Server Error 404 page. I even tried making the first call of the 'old' URL absolute. No luck! I just want these old pages to redirect to the homepage.

Redirect 301 /summer_autumn/index.htm http://www.url.com

Redirect 301 /activity_groups/index.htm http://www.url.com

Would appreciate any suggestions. Thank you!

    This topic has been closed for replies.

    2 replies

    Legend
    August 9, 2019

    who's your web host ?

    Paul-M - Community Expert
    Legend
    August 6, 2019

    That looks ok to me - maybe some other issue - have you checked with your web host?

    Alternative approach if you have mod_rewrite enabled:

    RewriteCond %{REQUEST_URI} ^/summer_autumn/index.htm [OR]

    RewriteCond %{REQUEST_URI} ^/activity_groups/index.htm

    RewriteRule (.*) http://www.url.com/? [L,R=301]

    Paul-M - Community Expert
    r_tistAuthor
    Inspiring
    August 6, 2019

    Is mod_rewrite something that needs to be enabled on the server? (not too familiar with)

    Thank you.

    Legend
    August 6, 2019

    Assuming you are on an apache web server, in apache configuration file (httpd.conf) look for this:

    #LoadModule rewrite_module modules/mod_rewrite.so 

    remove the hash at the start to enable the mod_rewrite module:

    LoadModule rewrite_module modules/mod_rewrite.so 

    then restart apache...

    Typically the the apache config file it at one of these locations:

    1. /etc/apache2/httpd.conf
    2. /etc/apache2/apache2.conf
    3. /etc/httpd/httpd.conf
    4. /etc/httpd/conf/httpd.conf
    Paul-M - Community Expert