Articles of .htaccess

phpMyAdmin(具有别名)如何与不同的documentRoot的虚拟主机子域相关联

为了提高我的服务器的安全性,我只为admin创build了一个子域名,比如admin.domain.tld ,通常我只通过admin.domain.tld/mysqladmin访问phpmyadmin,就像在configuration文件中一样: <VirtualHost *:80> ServerName admin.domain.tld Alias /mysqladmin /usr/share/phpMyAdmin/ <Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 AllowOverride All […] </VirtualHost> 现在我已经有一个子域我想要SSL安全它,因为我需要configuration一个虚拟主机或类似的东西(我使用certbot aka让我们encryption),但是因为我必须configuration一个虚拟主机,我决定创build一个pipe理员只有在admin.domain.tld包含链接到我的pipe理页面,如phpmyadmin,joomlapipe理页面等html页面… configuration文件: ServerName admin.domain.tld DocumentRoot /var/www/admin.domain.tld ErrorLog /var/log/httpd/admin.domain.tld/error.log <Directory /var/www/admin.domain.tld> Options FollowSymLinks Indexes AllowOverride All </Directory> 但现在当我去admin.domain.tld/mysqladmin我得到一个错误: The requested URL /mysqladmin/ was not found on this server. 所以,我怎么能这样工作: admin.domain.tld是/var/www/admin.domain.tld 和 admin.domain.tld / mysqladmin是phpmyadmin 编辑:我想我的问题是别名不工作,所以当我去admin.domain.tld它显示/var/www/admin.domain.tld/mysqladmin而不是/ usr /共享/ phpMyAdmin

当访问所有其他文件被拒绝时,如何dynamic地将所有HTTP错误代码发送到一个PHP文件?

我有以下情况,我正在开发一个API。 我将所有stream量重写为一个名为: route.php PHP脚本,使用mod_rewrite : 1: RewriteEngine On 2: RewriteCond %{REQUEST_FILENAME} -f [OR] 3: RewriteCond %{REQUEST_FILENAME} -d 4: RewriteRule ^.* route.php [L] 其他文件不应该是可访问的,这就是为什么我只使用白名单来访问route.php 。 为此我使用这个: order allow,deny <FilesMatch "route\.php"> allow from all </FilesMatch> 我想发送所有的1xx,2xx(200除外),4xx,如果可能的话5xx HTTP状态码给PHP脚本(假设error.php?code=404 ,显示该状态码的dynamic错误页面。我可能error.php不允许在FilesMatch部分中访问error.php 。 我在本文中描述了部分我想要的东西,但我无法实现或设法按照上述方式使其工作。 我的目的是为了显示一个JSON输出(dynamic地基于状态码),如{'statusCode':'404','status':'Not Found'}包括我使用的所有常见(安全)HTTP头。

.htaccess重写模块在Windows下不能在Apache下工作

我试图将请求redirect到一个文件夹备份到我的Apache服务器的根目录中的一个文件, index.py 。 到目前为止没有任何工作。 这是我的.htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteCond %{HTTP_REFERER} !index\.py RewriteRule . index.py [L] </IfModule> 这仍然让我喂它的url,如www.example.com/files/testfile.zip和下载。 它需要回到index.py 。 我已经取消了httpd.conf mod_rewrite.co注释。 这是在Windows中。

Linux Mint – Apache 2.4 .htaccess rewriteRule不起作用

我有一个网站使用.htaccess重写规则,但有些不起作用。 这是我的.htaccess文件: RewriteEngine On RewriteBase / # Inicio RewriteRule ^inicio|home|index$ index.php [QSA,L] # Paginacion amigable RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)\.([0-9]+)$ $1?pag=$2 [QSA,L] # Miniaturas RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*\/)?tdd([A-Za-z0-9_~-]*)\/(.*)$ imagen.php?param=$2&src=$1$3 [QSA,L] #paginas RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*-p([0-9]+)$ interna.php?id=$1 [QSA] #Intranet RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d […]

分派器上的Apache重写规则

我怎样才能做一个重写规则http://example.com/abc重写/redirect到http://example.com/abc.html但它应该工作时,我的URL为http://example.com/abc/def.html 。 目前,当我redirect 301 "abc" "abc.hml" ,第二个URL也redirect到http://example.com/abc.html/def.html 。 我目前的规则。 <IfModule rewrite_module> RewriteEngine On RewriteRule ^/$ /content/aaa-123/abc.html [PT,L] RewriteRule ^/index.html$ /content/aaa-123/abc.html [PT,L] RedirectMatch ^/abc$ /abc.html RewriteCond %{REQUEST_URI} !^/(.*)/$ RewriteCond %{REQUEST_URI} !^(.*)\.(.*)$ RewriteRule ^/(.*)$ /content/$1/ [L] RewriteRule \.(css|jpe?g|gif|png|js)$ – [L] ErrorDocument 404 /errors/404.html <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" […]

Ubuntu 14服务器 – 在下载文件之前设置用户名密码提示

我有一个Ubuntu 14服务器(我正在使用一个LAMP堆栈),它目前正在托pipe一个我做的网站。 我已经上传了一个zip文件,任何有链接的人都可以下载并下载。 但是,这可能会非常快速地出现问题。 比方说,这些文件可以转到如下path: homepage.com/src/file1.zip 任何有足够好奇心的人都可以继续,inputhomepage.com/src/并查看整个目录,然后开始下载他们可能在那里看到的其他文件。 它也不会阻止他们试图访问其他文件夹,如homepage.com/source/ ,只是尝试和钓鱼文件夹。 为了防止这种情况,我的想法是为我的文件夹/文件创build一个“AuthFile”,以便当有人绊倒它时,他们必须input正确的用户名密码才能下载它。 这将与本教程中所示的保护phpMyAdmin页面类似,并将导致此提示: 但是,在创buildAuthFiles后,我不认为我可以将其应用于文件夹或文件。 因此,让我回到我的主要问题: 我怎样才能提示用户input用户名密码组合才能下载文件? 如果这不是一个选项,你们如何pipe理谁来下载服务器上的某些文件,确保没有人只是pipe理你的文件? 任何帮助和指导,非常感谢。

url被附加到redirect链接htaccess

在我的.htaccess文件中,每当我创build301redirect时,要被redirect的url被附加到要被redirect到的url。 例如: Redirect /linksresources.html http://example.com/resources/ 将redirect到: http://example.com/resources/?/linksresources.html 现有的.htaccess文件: #404 Custom Error page #ErrorDocument 404 /error_docs/404.php #force IE out of compatibility mode <FilesMatch "\.(htm|html|php)$"> <IfModule mod_headers.c> BrowserMatch MSIE ie Header set X-UA-Compatible "IE=Edge,chrome=1" </IfModule> </FilesMatch> #Disable Indexing Options -Indexes Order Deny,Allow Allow from All Redirect /linksresources.html http://example.com/resources/ RewriteEngine On RewriteOptions inherit #if request is not an […]

htaccess在特定的域redirect到特定的path

我将redirect我的域到特定的path。 我想要的是 admin.example.com to admin.example.com/admin partner.example.com to partner.example.com/partner 我需要在一个.htaccess文件中的这两个function。 谢谢。

redirect选项在.htaccess文件中删除后redirect

我使用重写规则在我的apache服务器上做了一些redirect的事情,它运行良好,在我删除了这个选项之后,我的浏览器得到了redirect链接,但是当我在其他系统中testing它时,它并没有。 这对我来说很奇怪,我不知道是什么问题。 有没有逻辑解释这个或我梦想? 我在客户端使用win 10,在服务器上使用apache-2.2,如果他们帮助。 坦克。

删除在Apache目录中的尾部斜杠

我有以下urlwww.example.com/advice/现在注意在URL的末尾的斜线? 我希望将其移除为www.example.com/advice 。 现在,当我在浏览器中input该URL时,我将redirect到带有斜线的尾部,即使以curl为例。 现在我知道后面的斜杠正在增加,因为通知是一个实际的目录。 [steve@dev dev.www.example.com]$ curl -I https://dev.www.example.com/advice -k HTTP/1.1 301 Moved Permanently Date: Fri, 25 Nov 2016 08:20:11 GMT Server: Apache/2.4.6 (CentOS) Location: https://dev.www.example.com/advice/ Cache-Control: max-age=0 Expires: Fri, 25 Nov 2016 08:20:11 GMT Connection: close Content-Type: text/html; charset=iso-8859-1 [steve@dev dev.www.example.com]$ curl -I https://dev.www.example.com/advice/ -k HTTP/1.1 200 OK Date: Fri, 25 Nov 2016 […]