我有一个工作在https://example.com YOURLS安装,它有一个手中充满了可以在URL中传递的触发器。 https://example.com/this是一个redirect,但是如果你用+前缀,以便得到https://example.com/+this我们得到一些自定义函数。 同样,如果我们将https://example.com/this+添加到URL的末尾,就像https://example.com/this+那样,我们可以显示一些统计信息等。 我如何通过子域代理这些function,以便当https://a.example.com/this被请求时,用户被呈现与来自https://example.com/+this相同的数据,但是在新的url,当https://b.example.com/this被请求时,用户看到的结果与https://example.com/this+相同? this使用了一个字符集[a-zA-Z0-9] 我似乎无法得到任何与此。 我知道, mod_rewrite可以在这里帮助, mod_proxy将需要,可以匹配正则expression式, SSLPRoxyEngine on需要设置,什么是最好的方法?
我从这个URLredirect www.example.com/article.php?id=12&title=some-title 到这个URL www.example.com/article/12/some-title 使用这些URL重写规则 RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /(article)\.php\?id=(\d+)&title=([\w-]+)\ HTTP RewriteRule ^article\.php$ /%1/%2/%3? [R=301,L] RewriteRule ^article/(\d+)/([\w-]+)$ article.php?id=$1&title=$2[R=301,L] 但是,例如,如果URL中有一个空格 www.example.com/article.php?id=12&title=some%20title 那么上面的规则将不起作用。 我怎样才能让这个URL使用上面提到的规则只使用.htaccess ?
我的一个客户有一个网站,作为example.com 。 他希望以example.com/pl的forms提供服务,为未来的英文网站版本保存根path。 我想知道这是否可以使用.htaccess规则。 当前.htaccess如下所示: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ – [NC,L] RewriteRule ^.*$ index.php [NC,L] 规则可以改变,以达到客户的期望? 如果是这样,怎么样?
我正尝试别名path到特定的文件 我试过了: Alias /Console "/console/console.html" 现在去http://example.com/Console确实带来了console.html 。 但从console.html (即, images\1.jpg )引用的任何相对资源失败,因为它似乎去到document_root 我究竟做错了什么?
我有一个应用程序,所有到URLpath/playback的stream量必须由PHP脚本authCheck.php 。 这是好的,但我需要保留在浏览器中的原始URL的CSS URL标签: RewriteRule ^/playback/(.*)$ http://%{HTTP_HOST}/authCheck.php?file=proxy/playback/$1 [NC] <Proxy *> Order deny,allow Allow from all #Require ip 127.0.0.1 </Proxy> Header add "Access-Control-Allow-Origin" "*" ProxyPass /proxy/playback https://clientdomain/playback ProxyPassReverse /proxy/playback https://clientdomain/playback 任何人都知道如何做到这一点?
我有一个主域,几个附加域,最近去了HTTPS。 这对我来说可行,但我希望你的意见: ## All http requests to the relative https url RewriteCond %{SERVER_PORT} 80 [OR] ## redirect the other domains and the non www main main domain RewriteCond %{HTTP_HOST} ^domain3.com [OR] RewriteCond %{HTTP_HOST} ^www.domain3.com [OR] RewriteCond %{HTTP_HOST} ^domain2.com [OR] RewriteCond %{HTTP_HOST} ^www.domain2.com [OR] RewriteCond %{HTTP_HOST} ^maindomain.com ## this stuff is for SSL RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ […]
我有两个文件夹,F1和F2,在我的公共文件夹下,每个都有一个.htaccess文件。 F1受到.htaccess中的基本身份validation的保护,如下所示: AuthName "Restricted Area" AuthType Basic AuthUserFile /home/myaccount/.htpasswd AuthGroupFile /dev/null require valid-user 我正在从F2重写一个url到F1,如下所示: RewriteRule ^f2file\.php$ ../F1/f1file.php [NC,L] 这个重写很有效,但是我用我在F1中设置的基本authentication来挑战我。 有没有办法发送基本身份validation与重写,或绕过基本身份validation从本地文件夹重写时? 我试过设置一个像这个问题一样的环境variables: SetEnvIf Request_URI ^f2file\.php$ ADD_BASIC_AUTH RequestHeader set Authorization "Basic XXXXXXXX" env=ADD_BASIC_AUTH 其中XXXXXXXX是user:pass的base 64编码值,如上面问题所述。 但是,这不起作用,它仍然挑战我的凭据,也许是因为我没有做重写作为代理? 有任何想法吗? 谢谢!
我将我的网站转换为ssl 。 我的htaccess目前有现有的规则,我想添加一个规则来重写所有http请求到https (这是一个共享服务器,我没有访问configuration文件,所以这是唯一的方法)。 主要的两个规则是第一个( http到https )和最后一个(移除www )。 我试图包围我的头是在这种情况下链接规则会发生什么,如果我需要[L]指令与http重命名规则的https 。 我知道[L]指令会导致一个.htaccess循环,并且如果可能的话只传递一个规则会更有效率。 如果不使用[L]指令(使用http指向https重命名规则),那么www重命名规则是否仍然能够一次传输? RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301] #Rules for Versioned Static Files – remove timestamp RewriteRule ^(js|js-common|css|css-common|img|img-common)/(.+)\.([0-9])+\.(js|css|php|jpg|gif|png)(.*)$ $1/$2.$4$5 [L] #rename invalid file and directory requests RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?redirectroot=%{REQUEST_URI} #direct favicon requests to img directory RewriteCond %{REQUEST_URI} […]
是否有可能重写/代理一个URL到另一个具有不同path的URL? 它不应该只是一个redirect,而应该是其他URL的内部代理,以便浏览器地址栏只显示原始URL。 请注意,这两个url的域名/主机名称会有所不同。 请build议。 eg Rewrite or Proxy from, https://www.example1.com/a/b to https://www.example2.com/p/q/r
基本上,我主持一个静态的HTML网站,我需要: http://example.com/some-direcory/index.html 被redirect到: http://example.com/some-direcory 虽然仍然有物理文件代表的内容存储在: http://example.com/some-direcory/index.html 这是我有: # rewrite /dir/file to /dir/file/index.html RewriteRule ^([\w\/-]+)(\?.*)?$ $1/index.html$2 [L,T=application/x-httpd-html] 这似乎对我上面的#2需求很好,然后我有这个满足我对#1的需求: # rewrite /dir/file/index.html to /dir/file RewriteRule ^(.*)/index\.html$ /$1 [R=301,L,C] 但是,当我将这两个规则结合在一起时,他们显然会创build一个redirect循环 有什么办法可以解决吗?