rewriteRules does not appear to work (2.7.13)
See original GitHub issueRunning on Windows 8.1 64-bit in git-bash.
$ node --version
v0.12.4
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
gulp.task('watch', ['serve'], function () {
gulp.watch('./**/*.*', reload);
});
gulp.task('serve', function () {
browserSync.init(null, {
server: {
baseDir: './',
directory: true
},
port:5000,
ghostMode: {
clicks: false,
location: false,
forms: false,
scroll: false
},
rewriteRules: [
{
match: /WebsiteUrl/g,
fn: function (match) {
return 'TEST';
}
}
],
injectChanges: false,
notify: false,
reloadDelay: 0//1000
}, function (err, bs) {
require('opn')(bs.options.getIn(["urls", "external"]));
console.log('Started connect web server on ' + bs.options.getIn(["urls", "external"]));
});
});
gulp.task('default', [], function () {
gulp.start('serve');
});
{
"name": "emailtemplates",
"version": "1.0.0",
"description": "Email Templates for the Website project",
"author": "",
"devDependencies": {
"browser-sync": "^2.7.13",
"opn": "^3.0.2"
}
}
Any ideas? Really frustrating. It seemed to work a few times, but not globally.
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
RewriteRule doesn't seem to work, but RedirectMatch does
I'm trying to use a RewriteRule to redirect requests for URLs to an updated URL string. This is for a WordPress site. /category-about...
Read more >Error 403.14 when first attempting to access Symfony app in ...
When attempting to access it directly as below, it did work. So it seems that the .htaccess files are not being taken into...
Read more >htaccess 301 Redirect does not work - ProcessWire
I used the Redirects Module. The URLs look as follow (all similar). old url: www.mysite.de/page.html or www.mysite.de/ ...
Read more >What is meant by RewriteCond and RewriteRule in htaccess?
The RewriteRule pattern (a regex) matches the URL-path from the requested URL, which notably excludes the query string (you must use a RewriteCond...
Read more >RewriteRule Flags - Apache HTTP Server Version 2.4
Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner. That is, it doesn't care whether letters appear...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@shakyShane That is great - I just wish that was in the documentation 😉
However, the issue was it only worked sometimes.
Anyway, I’m sure this bug will crop up somewhere else.
Thanks.
Finally got it to work by reading this article: https://vinaygopinath.me/blog/tech/url-redirection-with-browsersync/ I had to specify middleware directly as a function, as described in the article above. When middleware is defined as described in the documentation, as an array of objects, it doesn’t work (i.e. trying to redirect by setting req.url doesn’t work).