我有一个Apache的反向代理,我试图做一个规则redirectexample2的几个url到example1,但我的重写规则不起作用。 我已经在example2的虚拟主机中尝试了这一点: ProxyPass / https://example1.com/index2.html ProxyPassMatch ^[A-Za-z0-9]$ https://example1.com/news-$1 第一个规则的工作,但不是第二个与ProxyPassMatch,当我去https://example2.com/1test05 ,返回一个404错误,但直接访问https://example1.com/news-1test05工作。 任何想法?
我觉得这很容易,但是恐怕我自己也解决不了这个问题。 我已经将网站移到了另一个域,并且设置了一些永久redirect。 但是,我想保留一个URL从任何重写。 现在我的configuration是这样的: Redirect permanent /olduser/exception/ ??? Redirect permanent /olduser/dir/ http://newuser.domain.com/a.html Redirect permanent /olduser/other/ http://newuser.domain.com/q.html Redirect permanent /olduser/other/sub/ http://newuser.domain.com/t/some.html Redirect permanent /olduser/ http://newuser.domain.com/ 当然,第一行是有问题的,因为我将最后一行的整个子目录redirect到新的域。 在新的域我没有特权 ,因为它是一个类似于GitHub的静态网站。 请注意,我不能简单地使用重写规则,因为旧的目录不对应于新的文件/目录。 或者更好, 我不明白我怎么能做到这一点:) 如何在旧的服务器上创build/olduser/exception/工作,而不影响其他规则? 谢谢!
假设我有一个通过HTTPS提供的网站,例如https://example.com/foo 。 考虑下面的.htaccess : RewriteBase / RewriteEngine On RewriteRule ^foo$ bar [R=301,L] 现在,当我访问https://example.com/foo ,它会通过HTTP而不是HTTPSredirect到http://example.com/bar 。 我怎样才能使它转到HTTPS而不是使用R标志的每个RewriteRule使用完整的scheme+主机? 也就是说,这会做我以后的事情: RewriteBase / RewriteEngine On RewriteRule ^foo$ https://example.com/bar [R=301,L] 但是,我的.htaccess文件包含许多这样的RewriteRule ,感觉应该有一种方式告诉Apache / mod_rewrite“重写为https://默认情况下”。 我真正想要的是告诉Apache网站使用的是HTTPS,类似于通过ServerName foo.ext声明主机名的ServerName foo.ext 。 那可能吗? 我猜这是堆栈溢出类似的问题: 如何说服Apache的原始客户端协议
我在共享主机上有我的页面。 一般来说,该网站可以使用http和https访问。 该页面投放广告,而且大部分广告都不能使用https,因此我只希望通过https访问pipe理部分。 我想要的是: http://myurl.com/auth -> https://myurl.com/auth http://myurl.com/admin -> https://myurl.com/admin https://myurl.com/allotherstuff -> http://myurl.com/allotherstuf 基本上所有的授权和承认请求都应该被redirect到使用ssl。 其他站点的请求应该从httpsredirect到http(如果使用https请求页面)。 我尝试了下面的.htaccess文件,这使得“auth”和“admin”无法访问(太多的redirect)。 <IfModule mod_rewrite.c> RewriteEngine On #Redirect other sites to http RewriteCond %{HTTPS} =on RewriteCond %{REQUEST_URI} !^/?auth.*$ RewriteCond %{REQUEST_URI} !^/?admin.*$ RewriteRule ^/?(.*) http://%{SERVER_NAME}/$1 [R,L] #Redirect auth and admin to https RewriteCond %{HTTPS} !=on RewriteRule ^/?auth/(.*) https://%{SERVER_NAME}/auth/$1 [R,L] RewriteCond %{HTTPS} !=on RewriteRule […]
我有两个域名: domain1.com domain2.com 我有一个Apache 2服务器,一个文件根/svr. 我想要发生以下情况: domain1.com路由到相当于/svr/examplepath/thisisadir/param/domain1 domain2.com路由到相当于/svr/examplepath/thisisadir/param/domain2 我已经尝试在/svr,使用带有RewriteEngine的.htaccess ,在站点中使用VirtualHost声明 – 可用于每个主机名,并简单地使用301redirect。 不过,我不能使用简单的301,因为用户仍然应该在浏览器中看到domain1.com 。 即domain1.com/about-this-site应映射到/svr/examplepath/thisisadir/param/domain1/about-this-site. 我不能得到RewriteEngine将主机名路由到他们各自的端点,任何意见将不胜感激。 我目前正在尝试在服务器根目录下的.htaccess中使用HTTP_HOST ,但重写规则仍然没有生效。 Ilmiont
我意识到这个规范性的问题,并已经阅读,但我似乎无法在那里find一些东西。 这里是我的条件和规则删除www和强制https : RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L,NE] RewriteCond %{HTTPS} off RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE] 我明白我想要匹配什么。 但是替代规则对我来说有点不清楚。 我不明白的是: 我的主机名(没有www. )如何以%1结尾? 为什么在应用第二条规则时查询string不会丢失? 第二个问题背后的原因是手册明确指出(由我强调): REQUEST_URI 请求的URI的path组件,例如“/index.html”。 这明显地排除了作为其自己的variablesQUERY_STRING可用的查询string 。
我有这个Apacheconfiguration: <VirtualHost *:80> DocumentRoot "/home/example/public_html/" ServerName www.example.com <Directory "/home/example/public_html/"> allow from all RewriteEngine on RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] </Directory> </VirtualHost> redirect似乎从来没有火,只是从http服务的文件。 我尝试了各种组合,但似乎没有任何工作。 mod_rewrite已启用(使用LoadModule rewrite_module modules / mod_rewrite.so) 谁能帮忙?
我通过它的Windows安装程序安装了Apache,然后安装了PHP和MySQL。 WordPress的工作正常,这意味着所需的基本设置工作正常。 但不知何故mod_rewriting是行不通的,即使我已经从httpd.conf取消了LoadModule ….. mod_rewrite注释。 每当我去我的localhost一些固定链接,我只是得到一个404(基于浏览器,而不是基于WordPress)。 请build议我需要做的改变。
好吧,在这里! 即时运行的Linux(cent os),我的httpd.conf文件中有“LoadModule rewrite_module modules / mod_rewrite.so”启用! “mod_rewrite.so”位于modules文件夹中。 这里是一些代码 HTTPD.CONF: <Directory /> Options All AllowOverride All </Directory> <Directory "/var/www/html"> Options Indexes All AllowOverride All Order allow,deny Allow from all </Directory> VHost文件: # owned by VirtualHost NameVirtualHost 192.168.10.200:80 # FrontPage needs the following four things to be here # otherwise all the vhosts need to go […]
是可以直接在Apache httpd.confconfigurationWordPress永久链接? 我有一个服务器的情况(Apache 2.2.3 CentOS PHP5.1.6),我不能使用.htaccess的性能的原因,但可以使用httpd.conf。 pipe理员说,mod_rewrite已启用,但AllowOverride不是,我不能改变这些设置。 我需要限制永久链接到“博客”目录。 这是什么将进入.htaccess但需要进入httpd.conf: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L] </IfModule> 谢谢…