Zen Cart Logo
Forums / General Questions / htaccess Redirect syntax

htaccess Redirect syntax

Locked

Views: 1,657

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
23 Feb 2010, 1:57 AM
#1
hedron avatar

hedron

Zen Follower

Join Date:
Feb 2009
Posts:
138
Plugin Contributions:
0

htaccess Redirect syntax

currently I have this htaccess syntax:
RedirectMatch ^/$ http://www.example.com/store

Which worked fine until I decided to install a blog as well.

With that syntax anyone that goes to example.com gets redirected automatically to the store.

However now that I have a blog under the /blog subfolder it will also redirect all blog pages to the store, returning a page not found error.

What kind of htaccess syntax should I use to do the following:

  1. Redirect the main url https://www.example.com to the /store subfolder
  2. Allow me to run a blog under the /blog subfolder without conflicting with the redirection.

This is the content of my entire htaccess file within the root directory ( right above the /store subfolder)


RedirectMatch ^/$ http://www.example.com/store
Options -Indexes

The following adds the www if it's missing:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursite.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

The following makes sure the correct mime type is sent for the .htc file

AddType text/x-component .htc

Redirects 404 error page to custom page

ErrorDocument 404 http://www.example.com/store/index.php?main_page=page_not_found

Redirects 500 error page to custom page

ErrorDocument 500 http://www.example.com/store/nddbc.html

Redirects 503 error page to custom page

ErrorDocument 503 http://www.example.com/store/nddbc.html

Block specific hacker activity

redirects any URL that includes: record_company.php/password_forgotten.php

RedirectMatch Permanent ^/(.*[record_company.php]+)/(password_forgotten.php)$ /page_not_found.php

redirects any URL that includes: /images/wp- with 'wp-' being anything that ends with '.php'

this allows for images named such as 'wp-header.jpg' to work

RedirectMatch Permanent ^/(.[images]+)/(wp-..php)$ /page_not_found.php

Thank you!