Tag: mod rewrite

使用服务工作者时,请脱机重写URL

我正在使用由名为sw-precache的Nodejs插件生成的服务工作程序来创build具有脱机function的Web应用程序。 一切工作正常,我可以离线访问HTML文件或图像。 但是,因为你没有服务器端语言可能,有没有一种方法来重写URL客户端像.htaccess文件会做? 像没有文件匹配的url时显示“404网页找不到”页面? 我知道redirect可能使用Javascript或元标签,但重写url?

Nodejs&Angularjs,清洁url

如何设置节点/angular度以使index.html/app在example.com运行,而不是在example.com/app/index.html#/home 我试图把index.html放在节点服务器的根目录下,但是仍然把url作为example.com/index.html#/home

browserSync的modRewrite不适用于angularjs html5mode的path“app / index.html”与吞咽

当我运行gulp时,服务器以消息开始:不能得到/。 当我指向localhost:3000 / app / index.html时,站点redirect到localhost:3000 / home并正常工作。 但是,当我重新加载页面,它给:不能得到/ home。 请检查以下configuration,看看是否有遗漏: 访问path:app / index.html 这是我的gulpfile.js: var gulp = require('gulp'), nodemon = require('gulp-nodemon'), jshint = require('gulp-jshint'), browserSync = require('browser-sync') modRewrite = require('connect-modrewrite'); gulp.task('lint', function () { gulp.src('app/js/*.js').pipe(jshint()); }); gulp.task('serve', function() { browserSync({ server: { baseDir: "./", middleware: [ modRewrite([ '!\\.\\w+$ /index.html [L]' ]) ] } }); […]

使用grunt-contrib-connect和grunt-connect-rewrite删除文件扩展名

我试图从我的grunt web应用程序中的文件中删除“.html”。 http://testing.com/one/应该从该文件夹中返回index.html,但如果没有结尾的斜杠( http://testing.com/one ),它应该检查one.html 咕噜连接重写似乎是正常的,我可以find的例子,但从.html文件中删除文件扩展名似乎是杀了我。 这里的规则是类似于我在.htaccess文件中使用的规则。 connect: { server: { options: { port: 9000, keepalive: true, base: 'dist', middleware: function(connect, options) { return [ rewriteRulesSnippet, // Serve static files connect.static(require('path').resolve(options.base)) ]; } }, rules: { '^(.*)\.html$': '/$1' } } } 所以问题是,在这里使用正确的规则是什么?

Apache的mod_rewrite等同于node.js?

有没有一个等效的Node.js模块,做Apache的mod_rewrite呢? 还是有一个标准的语言结构,提供等效的function? 我刚刚开始使用Node,并将我的服务器转换为此平台。

通过PHP或Apache从服务器端上传HTTP文件

在将大文件(> 100M)上传到服务器时,PHP总是首先从浏览器接受全部数据POST。 我们无法注入上传过程。 例如,在我的PHP代码中,在将整个数据发送到服务器之前检查“ token ”的值是不可能的 : <form enctype="multipart/form-data" action="upload.php?token=XXXXXX" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="3000000" /> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> 所以我尝试使用这个mod_rewrite : RewriteEngine On RewriteMap mymap prg:/tmp/map.php RewriteCond %{QUERY_STRING} ^token=(.*)$ [NC] RewriteRule ^/upload/fake.php$ ${mymap:%1} [L] map.php #!/usr/bin/php <?php define("REAL_TARGET", "/upload/real.php\n"); define("FORBIDDEN", "/upload/forbidden.html\n"); $handle = fopen ("php://stdin","r"); […]