Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

htaccess & 301 redirect

Enthusiast ,
Aug 05, 2019 Aug 05, 2019

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!

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 05, 2019 Aug 05, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 05, 2019 Aug 05, 2019

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

Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 05, 2019 Aug 05, 2019

Yes, I'm assuming your on an apache web server? Please give more details about your hosting platform, are you on shared hosting?

Paul-M - Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 05, 2019 Aug 05, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 06, 2019 Aug 06, 2019

Looks like it's .net... so need web.config.

I have found different info online so do not know how to format correctly and which will work!

Here is one source I found: Any change you can plug in an example here of how it might look with a mock URL redirecting to another mock URL? I am confused by this caret character and abc.html. Ideally, I need to show redirects for two separate pages that will redirect to the homepage of a site.

<system.webServer>

    <rewrite>

      <rules>

         <rule name="URL1" stopProcessing="true">

          <match url="^abc.html" ignoreCase="true" />

          <action type="Redirect" url="Your current page path" redirectType="Permanent" />

        </rule>

      </rules>

    </rewrite>

</system.webServer>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2019 Aug 07, 2019

Ask your web host to help you.   Often this can be managed from your Plesk-panel.

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2019 Aug 09, 2019
LATEST

your on an IIS server by the looks of it HTTP Redirects <httpRedirect> | Microsoft Docs

Paul-M - Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2019 Aug 09, 2019

who's your web host ?

Paul-M - Community Expert
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines