Articles of .htaccess

htaccess保护目录不再工作?

不幸的是我的wp-login.php的保护不再起作用: <Files wp-login.php> AuthName "Forbidden access" Require ip 1xx.xxx.xx.x/24 </Files> 这是Apache的信息: Server version: Apache/2.4.10 (Debian) Server built: Aug 28 2015 16:28:08 错误日志没有显示任何内容:-(

有没有可能在.htaccess中有条件地设置php_value

我想根据主机服务器设置php_value ( error_log )。 如果是本地服务器: php_value error_log ./PHP_errors.log 如果是远程服务器: php_value error_log /home/user_id/public_html/PHP_errors.log 我试过使用 SetEnvIf Host "localhost" php_value error_log ./PHP_errors.log 但它返回错误。 我怎样才能做到这一点?

HTTPSredirect,排除子域 – Opencart

我只是切换到我的服务器上的HTTPS。 你能帮我使用.htaccessredirect所有stream量到https://,排除子域名: www.example.com -> https://example.com example.com -> https://example.com **.example.com -> http://*.example.com Here is my current .htaccess: # SEO URL Settings RewriteEngine On # If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ RewriteCond %{HTTP_HOST} www.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] […]

.htaccess规则给php文件500错误

我用了一个stackoverflow的答案来想出我想要做的。 我想请求http://myserver.com/book/1234实际显示内容forms的PHP文件http://myserver.com/book.php?id=1234 所以我的.htaccess看起来像这样: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} ^id=([0-9]*)$ RewriteRule ^book/(.*)$ /book.php?id=$1 [L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_URI}.php [L] 注意底部的两行允许我使用像http://myserver.php/login这样的url实际上拉起http://myserver.php/login.php这是正确的。 但是当我尝试调用http://myserver.com/book.php?id=1234时出现500错误。

.htaccessconfiguration不正常

这是我目前的情况: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d [NC] RewriteCond %{REQUEST_FILENAME} !-f [NC] #the rule RewriteRule ^post.php?id=([a-z0-9-]+)$ /post/$1.php # how my url's look like: http://localhost/post.php?id=article-slug-name # how i want them to look like http://localhost/post/article-slug-name ErrorDocument 404 /404.php 正如它在文件中所说的那样 我的url如何:http://localhost/post.php?id=article-slug-name 我希望他们看起来像http:// localhost / post / article-slug-name 我一直在尝试几天,search所有的论坛,只是不能使它的工作…该文件的作品,因为启用404页面命令我包括在最后的作品。 任何帮助表示赞赏!

用户请求目录URL时,使用htaccess授予对索引文件的访问权限

我想使用htaccess来允许访问索引文件加上一些其他的目录(index.php),但需要一个用户/通过目录中的其他一切。 现在我有: AuthName "SomeServer" AuthUserFile /path/to/.htpasswd AuthGroupFile /dev/null Require valid-user AuthType Basic <FilesMatch "(index.php)|(login.php)"> Allow from all Satisfy any </FilesMatch> 这允许用户访问index.php和login.php并拒绝目录的其余部分。 但是,只要用户请求URL中没有index.php的目录,如下所示: http://www.example.com/dir 提示用户login。 但是,如果用户在这里: http://www.example.com/dir/index.php 然后index.php显示没有login提示。 我需要更改哪些内容以允许用户访问http://www.example.com/dir,然后直接访问http://www.example.com/dir/index.php,而无需提示login需要在目录中的任何其他login? 更新:不知道它的问题,但我切换身份validation使用mod_auth_mysql。 仍然使用我的htaccess文件的同一部分,仍然面临同样的问题。

mod_rewrite用path后面的下划线replace所有的点

我已经在这里和所有标记的问题,但我的问题是不同的,因为要么replace“ . ”与“ _ ”是在一个特定的path后,我正在通过proxypass运行。 我正在尝试改变: http://somedomainname.com/grafana/dashboard/db/generic-ping?var-device=SF-some.machinename.com 至: http://somedomainname.com/grafana/dashboard/db/generic-ping?var-device=SF-some_machinename_com 码: 选项+ FollowSymLinks RewriteEngine On ProxyPreserveHost打开 ProxyPass / grafana http://100.65.7.97:3000 ProxyPassReverse / grafana http://100.65.7.97:3000 我已经尝试了很多东西,几个小时后,浏览serverfault / stackoverflow / webmasters.stackexchange /谷歌等。但我没有尝试成功redirect。 我不知道为什么。 我试过的一些东西(以及它们的变体): RewriteRule ^([^\.]*)\ (.*)$ $1_$2 [E=%E2:yes,N] RewriteCond %{ENV:%E2} yes RewriteRule (.*) http://%{HTTP_HOST}$1 [R=301,L] … RewriteRule ^(/?grafana/dashboard/db/.*/[^/]*?).([^/]*?.[^/]*)$ $1_$2 [N] RewriteRule ^(/?grafana/dashboard/db/.*/[^/]*?).([^/.]*)$ $1_$2 [R=301] … RewriteCond %{REQUEST_URI} […]

如何只redirect一个域名站点

我在我的文件夹.htaccess的所有网站redirect到https。 我只想将awesomesites.comredirect到https。 Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] RewriteCond %{HTTP_HOST} ^www\.awesomesites\.com [NC] RewriteRule ^(.*)$ https://awesomesites.com/$1 [R=301,L] RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] RewriteRule ^download/(.*) /index.php?route=error/not_found [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 目前它将所有网站redirect到https。

一个站点处理https请求,没有正确的ssl,其他生成\ x16 \ x03 \ x01错误

我们有两个站点,sub.example1.com和example2.com。 两者都不是专门configuration来处理SSL请求。 一个站点https:/sub.example1.com通过处理作为http请求来成功处理到端口443的安全请求。 对其他站点https://example2.com的安全请求超时并在Apache日志中logging“\ x16 \ x03 \ x01”错误。 这里是/ etc / httpd / sites-enabled / ServerAdmin webmaster @ localhost ServerName sub.example1.com DocumentRoot /opt/example1/web/ DirectoryIndex index.php index.html <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /opt/example/web/> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all # This directive allows us to have apache2's […]

使用htaccess将所有来自多个域的stream量redirect到单个域

我在我的服务器上托pipe了多个网站,所有这些网站都共享一个htaccess的相同代码库。 我需要这样的东西。 如果(域名!= example.com)redirect到example.com 如果有任何处理这个从htaccess的方式 使用以下但仍然不工作 RewriteCond !^(.*)$ https://example1.com/$1 [NC] RewriteRule ^(.*)$ https://example2.com/$1 [R=301,NC,L]