我希望将https://www.example.com/somePage.php?id=1234redirect到https://www.example.com/tool/1234 (以便传统链接和书签工作)。 我觉得我很接近,但这似乎不起作用… RewriteRule ^somePage.php?toolid=([0-9]+)$ /tool/$1 [R=301,L] 这里有什么问题?
我在我的Ubuntu Web服务器上调用了一个来自PHP的Node脚本,如 // The following PHP executes in the context of the Apache user – 'www-data' // $execstring = "node " . $args; exec($execstring, $output, $return_value); 如上所述,PHP代码在Apache用户的情况下执行,在Ubuntu上默认为www-data 。 我希望能够使用nvm切换www-data用户的节点版本 。 (注意:通过指定不同节点安装的完整path,我可以在不使用nvm的情况下切换节点版本 – 我还没有尝试过,但这不是我的问题。) 按照这里的说明,我很容易地为其他用户安装和使用nvm : curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash 和 nvm install 4.1.2 我发现我必须为每个用户分别安装nvm 。 这意味着当我运行上面的命令作为login用户( ubuntu )时, nvm不会为www-data用户安装。 而相反,切换我的节点版本的login用户( ubuntu )对www-data用户没有影响。 一个更重要的细节: www-data用户是特殊的。 […]
我正在使用类似于下面的.htaccess规则: # BEGIN Disable access to all files EXCEPT Order deny,allow Deny from all # Files <Files ~ ".(doc|xlsx|xlsm|xls|pdf|docx|txt|rtf|rdf|odf)$"> Allow from all </Files> # Page Content <Files ~ ".(css|js)$"> Allow from all </Files> # Images <Files ~ ".(jpe?g|png|gif|bmp|cur|ico|webp)$"> Allow from all </Files> # Fonts <Files ~ ".(svgz?|eot|otf|tt[cf]|woff2?)$"> Allow from all </Files> 但是,我也想允许一个特定的.php文件,我不希望将.htaccess规则放在特定的.php文件所在的文件夹中,所以我一直试图用FilesMatch 这里有些例子: <FilesMatch "\/folder1\/folder2\/folder3\/folder4\/\.(php)"> […]
我有两个Web应用程序:Jira和Mercurial。 他们曾经是在同一台服务器Dual Host但我已经把Mercurial移动到Mercurial Host 。 Jira仍然在Dual Host上Dual Host 。 Dual Host有一个Apache 2.2.22服务器,用于托pipeMercurial,但现在将作为反向代理。 在我的域名服务器上,我设置了jira来指向Dual Host的IP, mercurial指向Mercurial Host的IP。 用户通过访问http://dualhost:4040/和Mercurial访问Jira,访问http://dualhost/ 。 我已经设置了一个反向代理来代理请求http://dualhost/ to http://mercurial/ (以便现有链接在各个地方提交)。 这与以下configuration工作正常: <VirtualHost *:80> ServerName dualhost ProxyPreserveHost On ProxyPass / http://mercurial:80/ ProxyPassReverse / http://mercurial:80/ </VirtualHost> 现在我想代理http://jira请求到http://dualhost:4040但是我一直在代理Mercurial。 原因是我想在日后将Jira移动到新的服务器上,URL越“正确”越好。 我已经设置了这个规则: <VirtualHost jira:80> ServerName jira ProxyPreserveHost On ProxyPass / http://localhost:4040/ ProxyPassReverse / http://localhost:4040/ </VirtualHost> 我在看Apache 2.2的文档,这看起来应该工作。 我究竟做错了什么?
在我的网站的新服务器,一个centOS,当我尝试通过PHP上传图像和文件名包含一个特殊的字符,如“my'file.jpg”,我得到一个禁止的页面,我甚至不能尝试通过PHP处理错误 在我find的日志文件 ModSecurity: Access denied with code 403 (phase 2). Match of "eq 0" against "MULTIPART_STRICT_ERROR" required. [file "/etc/httpd/modsec/00_asl_zz_strict.conf"] [line "53"] [id "330793"] [rev "2"] [msg "Multipart request body failed strict validation: PE 0, BQ 0, BW 0, DB 0, DA 0, HF 0, LF 0, SM , IQ 1, IH 0, IP 0, FL […]
我需要mod_rewrite重新映射传入的URL,以便它被AliasMatch捕获。 RewriteCond %{REQUEST_URI} ^/app/(.*)$ RewriteRule ^/app/(.*) ^/dev-dave/app/$1 RewriteCond %{REQUEST_URI} ^/static/(.*)$ RewriteRule ^/static/(.*) ^/dev-dave/static/$1 AliasMatch ^/(.*)/static/(.*)$ /var/www/html/cosmos/$1/dist/static/$2 AliasMatch ^/(.*)/app/(.*)$ /var/www/html/cosmos/$1/dist/index.html <Directory /var/www/html/cosmos> AllowOverride None Require all granted <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d </IfModule> </Directory> 这可能吗? 我无法得到这个工作。
我在我的httpd.conf文件中有这个: <VirtualHost IP.AD.DR.ESS:80> ServerName example.com Redirect Permanent / https://example.net/ </VirtualHost> 这成功地将以前在http://example.com上的所有内容redirect到https://example.net新对应位置。 但是,我发现一个目录example.com/specialdir/必须保留在旧服务器上,因为它需要访问的数据不在新服务器上。 (需要几个月才能完成涉及其他几十个站点的迁移。) 有没有一个合理的方法来解决这个问题在httpd.conf或者我将不得不使用一堆.htaccess文件? 我怀疑我能用<Location>容器做些什么,但是我不知道要find这些信息的正确问题。
我有随机IP不断瞄准我的Apache服务器。 我在日志中获得的样本: 80.108.96.31 – – [18/Aug/2017:16:16:08 +0000] "GET /machine.xml HTTP/1.1" 403 520 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)" 200.163.163.189 – – [18/Aug/2017:16:16:08 +0000] "GET /machine.xml HTTP/1.1" 403 520 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET […]
我有一个在以下规则的子域的htaccess: RewriteEngine On RewriteBase / RewriteRule ^feed([0-9]+)$ ../image.php?id=$1 [L] 所以基本上我想redirect请求从位于子域的饲料到位于主域(只是一个目录上面)的image.php文件。 使用../似乎不像PHP中的工作。 那么我怎么能重写到父目录中的文件?
我有一个适用于我的Apache的httpd.confconfiguration的规则,如下所示: <DirectoryMatch "^/.*/\..*/"> Order deny,allow Deny from all </DirectoryMatch> 它阻止访问隐藏的目录,如我们的webroot中的.git。 但是,我们使用的Web应用程序(Magento)使用媒体目录中的需要公开访问的.thumbs子目录。 我有一个在.htaccess工作明确禁止访问隐藏的目录的规则: RewriteRule (^\.|/\.) – [F] 但我似乎无法find上述行的允许版本。 上下文:我们不修改Apache httpd.confconfiguration文件的原因是我们希望只用基于代码的部署来解决这个问题,并且需要在每个生命周期环境中重新加载Web服务器的configuration。