我需要拒绝直接访问特定目录下的所有文件夹(*后端),但有一个例外。 有一个目录(*上传)必须通过浏览器访问。 布局可能是这样的: *backend/ |-admin |-system |-themes |-*uploads 我知道你可以通过在后台下面放置一个htaccess来拒绝所有访问: Order Deny,Allow Deny From All 此外,您可以通过在上载中放置不同的htaccess来覆盖此行为: Allow From All 这是行不通的,因为我的脚本无法访问主题下的资源。 什么是正确的htaccess组合看起来像? [编辑] 我必须用htaccess来实现这一点,修改http.conf不是一个选项。 修改如下所示的htaccess,并添加一个文件到主题,几乎有所需的结果。 问题是: 主题下的文件必须受到保护,不能直接访问,但仍然可以提供给网站 。 后端 #backend Order Deny,Allow Deny from all Allow from 127.0.0.1 Allow from xx.xx.xx.xx 上传 #uploads Order Deny,Allow Allow from all 主题 #themes Order Deny,Allow Deny from all Allow from […]
如何使用url重写,更改url http://www.mydomain.com/this-is-a-new-article 至 http://www.mydomain.com/this_is_a_new_article ? 使用: # RewriteRule ^(.+?)-(.+?)$ (.+?)_(.+?) [R=301,L,NE] ?
这里是我编译的.htaccess的安全性。 你看到有什么问题需要纠正吗? 这里有什么可能会搞砸一个合法的网站吗? 我是否涵盖了所有的基础知识? RewriteEngine on Options +SymLinksIfOwnerMatch Options -Indexes # disable the server signature ServerSignature Off <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # mysql related RewriteCond %{QUERY_STRING} union([^a]*a)+ll([^s]*s)+elect [NC,OR] RewriteCond %{QUERY_STRING} (order).*(by).*(\%[0-9A-Z]{0,2}) [NC,OR] RewriteCond %{QUERY_STRING} (waitfor|delay|shutdown).*(nowait) [NC,OR] RewriteCond %{QUERY_STRING} (union|and|\^).*(select).*(ascii\(|bin\(|benchmark\(|cast\(|char\(|charset\(|collation\(|concat\(|concat_ws\(|table_schema) [NC,OR] RewriteCond %{QUERY_STRING} (union|and|\^).*(select).*(conv\(|convert\(|count\(|database\(|decode\(|diff\(|distinct\(|elt\(}encode\(|encrypt\(|extract\() [NC,OR] RewriteCond %{QUERY_STRING} (union|and|\^).*(select).*(field\(|floor\(|format\(|from|hex\(|if\(|in\(|information_schema|insert\(|instr\(|interval\(|lcase\() [NC,OR] RewriteCond %{QUERY_STRING} (union|and|\^).*(select).*(left\(|length\(|load_file\(|locate\(|lock\(|log\(|lower\(|lpad\(|ltrim\(|max\(|md5\(|mid\() [NC,OR] RewriteCond […]
有可能有条件地在htaccess文件中包含另一个文件。 当我在本地工作时,我的apache设置与我的远程服务器不同。 每次我通过git把变化拉到舞台网站(它与现场服务器共享相同的设置),我必须将补丁应用到我的htaccess: diff –git a/.htaccess b/.htaccess index 4733ffa..1b39d24 100644 — a/.htaccess +++ b/.htaccess @@ -2,6 +2,15 @@ # Apache/PHP/Drupal settings: # +############################################ +## uncomment these lines for CGI mode +## make sure to specify the correct cgi php binary file name +## it might be /cgi-bin/php-cgi + + Action php5-cgi /cgi-bin/php5-cgi + AddHandler php5-cgi […]
我下载了一个名为sphpblog的简单PHP博客模板,并将其放在我的服务器上。 博客通过classlibrary.org访问。 该域redirect到服务器上的/ other / william / classlibrary文件夹。 我可以访问博客的主页,它显示得很好。 但是,当我尝试点击链接时,链接将转到classlibrary.org/other/william/classlibrary/linkname.extension,这会导致404错误。 我检查了博客的首选项,并没有select将其直接指向网站的根目录。 所以,我想有任何链接到classlibrary.org/other/william/classlibrary/filename.extensionredirect到classlibrary.extension。 而不是为服务器上的每个文件创build单独的html文件,这将需要一段时间,我可以以某种方式通过.htaccess文件做到这一点? 我的服务器运行的是PHP 5.2版,完整pathclasslibrary.orgredirect到/ home / content / r / t / e / rteder10 / other / william / classlibrary。 我无权访问pipe理员控制面板或访问权限或服务器本身。 这是Godaddy Linux主机。 任何帮助将不胜感激。
在我的网站,我试图实现友好的url 。 我有一个index.php文件和一个.htaccess文件在我的主机的公用文件夹。 我在.htaccess文件中使用以下代码: DirectoryIndex index.php RewriteEngine On RewriteRule ^article/([0-9]+)/$ ../Feed/Article.php?id=$1 因此,如果有人进入www.example.com/article/15/ ,它会通过GET加载通过15值的Article.php 。 但问题是, Article.php文件是在公共文件夹之外(因此../ )和Apache没有find它。 谁能帮我? 注意:我没有访问httpd.conf文件。
我正在使用htaccess重写我的url,以便我可以有很好的干净的url。 但是,相同的htaccess文件在我的本地服务器和远程服务器上做了不同的事情: 在我的本地服务器上,url是http://localhost/example/ ,在我的远程服务器上,url是http://example.com/ 。 对于我的本地服务器,我可以使用以下htaccessredirect规则: RewriteRule ^(.*)$ index.php?page=$1 [L,QSA] 但是,当我在远程服务器上使用它时,出现内部服务器错误。 相反,我必须使用这个:(注意斜杠) RewriteRule ^(.*)$ /index.php?page=$1 [L,QSA] 不幸的是,这在我的本地服务器上不起作用:这个重写规则在本地服务器上请求http://localhost/index.php而不是http://localhost/example/index.php 。 如何在远程服务器和本地服务器上进行这项工作?
我注意到我的.htaccess文件包含 <Files 403.shtml> order allow,deny allow from all </Files> 它允许403错误页面403.shtml被在“拒绝”行中指定的地址查看。 我只想显示(启用SEF的joomla)网站的主页(而不是任何其他页面),而不是显示错误页面。 我的微弱尝试是: <directory /> order allow,deny allow from all <directory> 但是,这只是令服务器不高兴。 什么是正确的方法来做到这一点?
我有类似的网站内容 mysite.com/index.php mysite.com/apps 现在我想把一个维护页面,以便将访问mysite.com或mysite.com/index.php的人将能够看到维护页面,但访问者将去mysite.com/apps或mysite.com/apps/index。 PHP不会redirect到维护页面。 我已经试过这些: 这将根和子文件夹redirect到维护页面。 RewriteEngine On RewriteCond %{HTTP_HOST} ^mysite\.com$ [NC] RewriteRule ^(.*)$ http://mysite.com/maintenance.html/$1 [R=301,L] 这没有做任何事情 RewriteEngine on RewriteCond %{HTTP_HOST} mysite\.com [NC] RewriteCond %{REQUEST_URI} ^/$ Rewriterule ^(.*)$ http://mysecondsite.com/ [L,R=301]
RewriteEngine on Options -Indexes DirectoryIndex index.php RewriteBase / RewriteRule ^user/([a-zA-Z]+)/([a-zA-Z]+)(/)?$ index.php?controller=main&function=$1&arguments=$2 [NC,L] 我可以去mysite.com/one/two去main->one(two) 我想以相同的方式路由子域请求。 我如何设置api.mysite.com这样的规则来达到以下效果? controller=api&function=$1&arguments=$2 [NC,L] (让我去api.mysite.com/one/two打api->一(二))