我试图用Apache 2.2.10和FastCGI来部署Rails 2.1.2(我知道是的,坏的,古老的,丑陋的)。 我的应用程序可以通过example.com/app/public/访问,但是我想通过example.com/app/访问它。 在我的.htaccess文件(在应用程序/目录!)我有: RewriteEngine On RewriteBase /app/ RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ public/dispatch.fcgi [QSA,L] 我怎样才能转发每个请求去app/到app/public/ ? 每次我尝试这个(例如,用RewriteRule ^.*$ public/$1 [QSA] ),我得到一个路由错误: No route matches "/app/" with {:method=>:get} 帮帮我?
我维护的一个客户请求重新devise一个网站,我们在子文件夹/ newsite /中完成所有的工作,并且打算让它在这个瞬间生存下来。 / newsite /是在wordpress中制作的,从我的理解中,WP保留了最初创build的所有URL。 在/ newsite /创build新的根目录还是将根目录的所有内容移动到/ oldsite /并将/ newsite /移动到根目录会更容易些? 请build议最佳路线,即mod_rewrite。
我试图redirect/文件夹/使用.htaccess但我所得到的是Apache HTTP服务器testing页。 我的根目录如下所示: / .htaccess -/folder -/folder2 -/folder3 我的.htaccess看起来像这样: RewriteEngine On RewriteCond %{REQUEST_URI} !^/folder/ RewriteRule (.*) /folder/$1 我究竟做错了什么? 我检查了我的httpd.conf(我正在运行Centos)和mod_rewrite库正在加载。 作为一个方面说明,我的服务器不是一个万维网服务器,它只是一个虚拟机,所以它的主机名是centosvm。 另外:我的httpd.conf看起来像这样: <VirtualHost *:80> ServerName taa.local DocumentRoot /var/www/html SetEnv APPLICATION_ENV "dev" Alias /taa /var/www/html/taa/public <Directory /var/www/html/taa/public> DirectoryIndex index.php AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
我一直试图设置以下没有成功。 我想/WebContent/<any-folder-name>/html/index.html通过http://<any-folder-name>.homelan.net 。 基本上homelan.net是一个本地域,启用通配符指向相同的IP地址。 我一直在尝试使用不同的RewriteRules,但目前还没有运气。
我的用户希望在PHP Web应用程序的CMS后端上传大文件(50-100MB)。 我可以在这个虚拟主机上全局调整PHP的upload_max_filesize和post_max_size设置,但是恐怕会使得拒绝服务攻击变得更加容易。 理论上,这两个设置可以根据目录进行调整(无论是在虚拟主机configuration文件,还是通过.htaccess文件),我只需要pipe理区域中的较大值。 不幸的是,这个应用程序在web根目录(单点入口)中只有一个start.php文件,并且其中包含了所有其他的PHP文件。 这似乎使每个目录设置不可能。 我已经尝试将CMS中使用的path与<Location>匹配,但即使使用正确的path,php_value指令也没有任何作用。 <LocationMatch ^/admin> php_value upload_max_filesize 100MB php_value post_max_size 100MB </LocationMatch> (mod_rewrite用于将/admin/content/bla这样的path转换为/start.php?_p=/admin/content/bla ,这就是为什么“start.php”文件名不出现在上述expression式中的原因。) 有什么办法可以做这个工作吗? 我也打开替代的build议; 例如,在我们的情况下,基于IP的设置可能是可能的。 TIA。
有没有可能使用htaccess来做到这一点? 用户访问 – > http:// mydomaina.com/dir/filename 它将显示 – > http:// mymainsite.com/anydir/mydomaina-filename的内容 我有一个htaccess的代码,但它不能正常工作,可能是缺less的东西 <IfModule mod_rewrite.c> RewriteRule ^dir/(.*)\.xml$ http://mymainsite.com/dir/%{HTTP_HOST}-$1.xml [P] </IfModule> 谢谢
我必须通过mod_rewrite从apache代理所有请求到另一个。 加载mod_proxy和mod_rewrite,我configuration了如下的Apache: <VirtualHost *:8009> Options +FollowSymLinks -Multiviews …… RewriteEngine on RewriteRule ^/abc/(.*) http://anotherhost/abc/$1 [P,L] …. </VirtualHost> 但阿帕奇返回我505。 这是Apache在重写日志上写的内容: – – [16/Sep/2010:14:13:06 +0200] [myhost/sid#7f9472e763b8][rid#7f94731a6c78/initial] (2) forcing proxy-throughput with http://otherhost/abc/ – – [16/Sep/2010:14:13:06 +0200] [myhost/sid#7f9472e763b8][rid#7f94731a6c78/initial] (1) go-ahead with proxy request proxy:http://otherhost/abc/ [OK] 这在错误日志上: [warn] proxy: No protocol handler was valid for the URL /abc/. If you are […]
我有一堆域,我想要去一个域,但该域的各个部分。 # this is what I currently have RewriteEngine On RewriteCond %{HTTP_HOST} ^.*\.?foo\.com$ [NC] RewriteRule ^.*$ ${domainmappings:www.foo.com} [L,R=301] # rewrite map file www.foo.com www.domain.com/domain/foo.com.php www.bar.com www.domain.com/domain/bar.com.php www.baz.com www.domain.com/other/baz.php.foo 问题是我不想让每个域都成为RewriteCond的一部分。 我试过了 RewriteCond %{HTTP_HOST} ^www\.(.*) RewriteRule (.*) http://%1/$1 [R=301,L] 但是这将为每个域都这样做。 我只想要映射文件中的域redirect,然后继续进行其他重写,如果它不匹配映射文件中的任何域。
我在mod_rewrite有一些麻烦。 所以我通过.htaccess来实现它,我可以在我的主要虚拟主机domain.com上工作 – 我想要它做的是重写http://domain.com强制它到https://domain.com ,它做得很好。 我想为具有以下redirect的一个IP使用基于名称的虚拟主机: http://domain.com – > https://domain.com http://staging.domain.com – > https://staging.domain.com http://test.domain.com – > https://test.domain.com http://beta.domain.com – > https://beta.domain.com domain.comredirect到https://domain.com ,但staging.domain.com不,虽然我可以访问https://staging.domain.com 。 .htaccess对于两者来说都是相同的,只是域名不同而已。 它似乎并没有为staging.domain.com做任何重写,我已经通过尝试将其重写到www.google.com进行了testing。 我有一个通配符DNSlogging,* .domain.com指向域IP。 有一种特殊的方式,我应该configuration虚拟主机来允许这个? 我一直在阅读Apache文档,它不支持多个基于SSL名称的虚拟主机。 但我可以访问https://domain.com和https://staging.domain.com就好了。 有什么想法吗? 感谢大家对此的帮助。
我正在Apache Web服务器(:8080)之前运行nginx(:80) Nginxconfiguration(snippet): location / { proxy_pass http://www.domain.tld:8080; proxy_set_header X-Real-IP $remote_addr; 如果我设置本地主机,而不是www.domain.tld,我的浏览器被redirect到http:// localhost:8080 。 Apache重写规则: RewriteEngine On Options +FollowSymlinks RewriteBase / RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !\..+$ RewriteCond %{REQUEST_URI} !/$ RewriteRule (.*) http://%{HTTP_HOST}/$1/ [L,R=301] RewriteCond %{REQUEST_URI} !v2/ RewriteRule ^(.*)$ v1/$1 [L] 到现在为止还挺好。 但是,每个链接(使用相对path)都显示为http://www.domain.tld:8080 / page,而不是停留在端口80上。 有没有办法通过重写规则来解决这个问题? 我不想使用绝对path。 谢谢