我有一个域,我试图为错误页面设置自定义redirect。 我的.htaccess文件看起来像这样: RewriteEngine On AddDefaultCharset UTF-8 DefaultLanguage en-US # disable TRACK and TRACE http methods. 'RewriteEngine On' is required! RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD|PUT|DELETE) RewriteRule .* – [F] Options All -Indexes ServerSignature Off <ifModule mod_headers.c> Header unset X-Powered-By </ifModule> <Files .htaccess> order allow,deny deny from all </Files> <IfModule php5_module> php_value session.cookie_httponly true #php_value session.cookie_secure true </IfModule> RewriteCond […]
请帮我在这里。 我想使用.htaccess根据请求来源redirect,例如: 用户请求: http://www.domain.com/subfolder/ 并应该redirect到: http://www.domain.com/ 这是非常简单的完成,但在网页上有一个链接: http://www.domain.com/subfolder/ 当请求来自该链接时,它应该工作。 换句话说,我的目标是强制所有用户通过其他url之前的主页,即使他们知道的网页url(书签或其他),这是一个有效的。 可能吗?
我在这种情况下: url: domain/var1/var2/var3/…/varn 我想在以下url中更改该url: url: domain?v1=var1&v2=var2&v3=var3/…/&vn=varn 我发现这样: RewriteRule domain/([^/]+)/([^/]+)$ domain/index.php?v1=$1&v2=$2 [QSA,NC] 但是,正如你所看到的,我必须手动指定所有的variables…有没有办法自动做到这一点? 类似于:有一个/([^/]+)加v{N}=${N} ? 谢谢
我有这个在我的Apacheconfiguration文件: <VirtualHost *:80> other stuff here Redirect permanent / https://example.com/ </VirtualHost> 这很好。 它redirect所有www.example.com => https://example.com 。 但问题是如果访问者键入https://www.example.com那么redirect不会发生。 我在443 VirtualHost下添加了相同的行 <VirtualHost *:443> other stuff here Redirect permanent / https://example.com/ </VirtualHost> 但是这不具有任何想法相同的效果吗?
我有我的.htaccess文件中的以下内容: RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !^www\. RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 它在浏览器中按预期工作,将所有stream量redirect到https://www.example.com/ 。 但我使用的POS系统自动将产品上传到网站,显然这个桌面应用程序不喜欢多个RewriteRule 。 它抱怨说,它的networking商店没有安装。 只要我删除了其中的一条规则,就很高兴。 所以我的问题是:有没有办法将它合并成一个RewriteRule ?
我有一个运行Apache + PHP-FPM + FastCGI的Ubuntu 14.04服务器,为用户主页提供服务。 为了安全起见,我在Apache的configuration中启用了: Header set X-Content-Type-Options: "nosniff" Header set X-Frame-Options: "sameorigin" Header set X-XSS-Protection: "1; mode=block" AllowOverride FileInfo已设置,因此用户可以在.htaccess文件中使用Header指令进行更多控制(如果需要的话)。 然而,似乎Apache没有兑现当CGI使用PHP( mod_headers没有发送标题时,文件是PHP ),即使Header always , .htaccess Header命令被忽略的PHP文件。 我的下一个想法是让用户修改他们的PHP代码来使用PHP header函数 ,以便他们可以将其设置为X,我可以使用setifempty应用这只有当用户没有。 经过一番尝试,我发现这些条目工作: Header set X-Frame-Options: "sameorigin" env=!SCRIPT_NAME Header always setifempty X-Frame-Options: "sameorigin" env=SCRIPT_NAME 没有envtesting,我发现第一个命令(即使是setifempty或merge )会添加一个头文件,以便在头文件中看到两个X-Frame-Options 。 那么,这是正确的方式呢? 如果env=SCRIPT_NAMEtesting足够了,还是有更好的testing来确定请求是否将由PHP-FPM / FastCGI或Apache本身处理?
我有一个网站结构设置如下,我试图为每个组织的访问级别,但没有指定<Directory>因为这需要修复结构(也就是说,如果我复制到不同的网站,到一个子文件夹,它将需要编辑所有.htaccess到新的位置)。 / app / – 允许所有,拒绝configuration/等 / app / templates / – 全部拒绝 / app / templates / mytheme / – 只允许所有的图片,javascript,css,字体 / app / lib / – 全部拒绝 我试过实现Apache2.4的新(ish)指令scheme: /etc/apache2/conf-enabled/security.conf … more stuff above … <Directory /> AllowOverride All Require all denied </Directory> … more stuff below … 并且在应用程序的根目录中添加Require all allowed to .htaccess ,同时在我希望拒绝访问的文件夹中添加Require […]
我正在一个专门的服务器(Debian)上运行Joomla的网站,我已经读过将.htaccess规则移动到apache2configuration文件可能会导致很好的性能改进( Apache HTTP Server Tutorial:.htaccess文件 )。 / etc / apache2中的主要configuration文件:apache2.conf 在apache2.conf中,有一些我能够理解的指令: AccessFileName .htaccess 和 Include sites-enabled/ 服务器只托pipe一个网站。 在启用网站的情况下,还有另一个文件包含其他指令:000-default: DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow […]
我试图设置标题,如果来源是一个特定的网站,以解决资源冲突我有(使用Mautic托pipe在一个子域)。 如果我为任何情况添加头文件,当我尝试使用Mautic时出现500错误,但从我的网站访问的资源起作用,因此我只想在我的网站是源时设置它们。 这是我的: RewriteEngine On #preserve HTTP(S) RewriteCond %{HTTPS} =on RewriteRule ^(.*)$ – [env=proto:https] RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ – [env=proto:http] <IfModule mod_headers.c> SetEnvIfNoCase Origin %{ENV:proto}://mysite.com ENV_SET SetEnvIfNoCase Origin %{ENV:proto}://mautic.mysite.com ENV_SET=0 Header add Access-Control-Allow-Origin %{ENV:proto}://mysite.com env=ENV_SET Header set Access-Control-Allow-Credentials true env=ENV_SET Header set Access-Control-Allow-Methods: GET, POST, PATCH, PUT, OPTIONS env=ENV_SET Header set Access-Control-Allow-Headers: Origin, Content-Type, […]
我有一个非常简单的重写规则,但它不工作。 我有以下几点: #old see edits for newer versions RewriteCond %{HTTP_REFERER} ^localhost:8080(/|$) RewriteRule ^/downloads/.* /somePackage/index.php?id=5 [NC,C] RewriteRule ^/downloads /somePackage/index.php?id=2 [NC,L] 它似乎没有通过RewriteCond ,为什么是这样呢? 当我尝试这个: RewriteRule downloads/? /somePackage/index.php?id=2 [NC,L] 它似乎工作localhost:8080/downloads 但是当我尝试: RewriteRule downloads/.*/? /somePackage/index.php?id=5 [NC,L] 它不起作用,为什么这不起作用? 我应该怎么做呢? 编辑: 我这是目前的代码,只适用于localhost:8080/downloads和localhost:8080/downloads/但不是当我添加一些东西后斜线 RewriteRule downloads/somedownload/? /somePackage/index.php?id=5 [NC,L] RewriteRule downloads/? /somePackage/index.php?id=2 [NC,L] 编辑2: 这里是使用的.htaccess代码。 # Only the URLs /downloads and /downloads/ (with and […]