Menu icon Foundation
htaccess

Where can i put a htaccess file? So it then being copyied to the finish site folders?

htaccess

Where can i put a htaccess file? So it then being copyied to the finish site folders?

Geoff Kimball almost 4 years ago

Which starter project are you using? The Basic Template or ZURB Template?

Jonas almost 4 years ago

ZURB Template

Geoff Kimball almost 4 years ago

You'll have to add a little extra code, because the structure of the project is fairly rigid.

Find the copy task in the gulpfile.js and add this at the top of the function, above the existing code:

gulp.src('src/.htaccess')
  .pipe(gulp.dest('dist/'))

That will copy .htaccess from the root of your src folder to the root of your dist folder.

Matthew Wall over 3 years ago

Has anyone successfully used this to redirect a page yet?

.htaccess has been copied the root dist folder correctly and I have a single line:

Redirect 301 /google.html http://www.google.com

 

google.html shows Cannot GET /google.html

 

Doesn't seem to work!

Kester Hynds about 2 years ago

In Zurb Foundation 6 you need to edit `gulpfile.babel.js`. Then you can add an `.htaccess` file in the src folder and it will get copied across. N.B. You still need to get your `.htaccess` syntax correct!

1. Create a new function (e.g. add it below copy function):

// Copy .htaccess
function htaccess() {
  return gulp.src('src/.htaccess')
    .pipe(gulp.dest(PATHS.dist));
}

 

2. Add `htaccess` to the build task:

// Build the "dist" folder by running all of the below tasks
gulp.task('build',
 gulp.series(clean, gulp.parallel(pages, sass, javascript, images, copy, htaccess), styleGuide));

 

3. Add a watch task to the `watch` function:

 

// Watch for changes to static assets, pages, Sass, and JavaScript
function watch() {
  gulp.watch(PATHS.assets, copy);
  gulp.watch('src/.htaccess', htaccess);
  gulp.watch('src/pages/**/*.html').on('all', gulp.series(pages, browser.reload));
  gulp.watch('src/{layouts,partials}/**/*.html').on('all', gulp.series(resetPages, pages, browser.reload));
  gulp.watch('src/assets/scss/**/*.scss').on('all', sass);
  gulp.watch('src/assets/js/**/*.js').on('all', gulp.series(javascript, browser.reload));
  gulp.watch('src/assets/img/**/*').on('all', gulp.series(images, browser.reload));
  gulp.watch('src/styleguide/**').on('all', gulp.series(styleGuide, browser.reload));
}

Lucy Holt about 2 years ago

Thanks for your reply. Really helped me too!

Arthur Jones over 1 year ago

These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer. Chase Bank Login