拒绝除/index.php和两个文件夹之外的所有文件夹(Deny from all folders except /index.php and two folders)
这是一个奇怪的配置,我会给你,但我想拒绝访问我们系统中的所有文件夹,但它必须能够访问,
/index.php (Wordpress bootloader) /wp-*/* (e.g. wp-content, wp-admin, etc.) /templates/* (some of our templates and custom content)
其他一切都被拒绝(并且有数百个文件夹)。
我遇到的问题是允许index.php和2个文件夹,然后拒绝/中的所有其他内容。
我应该能够接受,
http://example.com/ http://example.com/index.php http://example.com/wp-content/... http://example.com/wp-admin/... http://example.com/wp-includes/... http://example.com/templates/template.css http://example.com/templates/subfolder/js/file.js
拒绝,
http://example.com/thisIsAFolder http://example.com/thisIsAnotherFolder
这就是我所拥有的,
<VirtualHost *:80> ServerName example.com DirectoryIndex index.php DocumentRoot /var/www/ <Directory /> Order deny,allow Deny from all </Directory> <Files index.php> Allow from all </Files> <Directory "/var/www(/|/wp*/|/templates/)"> Allow from all Options FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L] RewriteRule . index.php [L] </Directory> </VirtualHost>
但我不断收到
Red Hat Enterprise Linux Test Page
(使用CentOS),它允许子目录,因为我允许/
。编辑
这是最终为我工作的Apache配置。 非常感谢Jon Lin的帮助。
<VirtualHost *:80> ServerName example.com DirectoryIndex index.php DocumentRoot /var/www/ # first, deny all access <Directory /> Order deny,allow Deny from all </Directory> # then start to allow access where required <Files index.php> Allow from all </Files> <Directory "/var/www/"> Allow from all Options FollowSymLinks RewriteEngine On RewriteBase / # go directly to index.php if it is accessed RewriteRule ^index\.php$ - [L] # re-write URL for wp-admin access RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] # re-write wp-* access to route through wp/ RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L] # re-write all .php files to route through wp/ RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L] # go directly to real files and directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] # respond to all other URLs by passing them through index.php RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # deny access if URL doesn't start with these RewriteCond %{REQUEST_URI} !^/(index\.php)?$ RewriteCond %{REQUEST_URI} !^/wp-[^/]+/ RewriteCond %{REQUEST_URI} !^/templates/ RewriteRule ^ - [L,F] </Directory> </VirtualHost>
This is an odd configuration, I'll give you that, but I'm looking to deny access to all folders in our system but it must be able to access,
/index.php (Wordpress bootloader) /wp-*/* (e.g. wp-content, wp-admin, etc.) /templates/* (some of our templates and custom content)
Everything else is denied (and there are hundreds of folders).
The problem I have is allowing index.php and 2 folders and then denying everything else inside /.
I should be able to accept,
http://example.com/ http://example.com/index.php http://example.com/wp-content/... http://example.com/wp-admin/... http://example.com/wp-includes/... http://example.com/templates/template.css http://example.com/templates/subfolder/js/file.js
and reject,
http://example.com/thisIsAFolder http://example.com/thisIsAnotherFolder
This is what I have,
<VirtualHost *:80> ServerName example.com DirectoryIndex index.php DocumentRoot /var/www/ <Directory /> Order deny,allow Deny from all </Directory> <Files index.php> Allow from all </Files> <Directory "/var/www(/|/wp*/|/templates/)"> Allow from all Options FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L] RewriteRule . index.php [L] </Directory> </VirtualHost>
But I continually receive
Red Hat Enterprise Linux Test Page
(using CentOS) and it allows for sub-directories because I allow/
.EDIT
This is the Apache config that ended up working for me. Big thanks to Jon Lin for the help.
<VirtualHost *:80> ServerName example.com DirectoryIndex index.php DocumentRoot /var/www/ # first, deny all access <Directory /> Order deny,allow Deny from all </Directory> # then start to allow access where required <Files index.php> Allow from all </Files> <Directory "/var/www/"> Allow from all Options FollowSymLinks RewriteEngine On RewriteBase / # go directly to index.php if it is accessed RewriteRule ^index\.php$ - [L] # re-write URL for wp-admin access RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] # re-write wp-* access to route through wp/ RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L] # re-write all .php files to route through wp/ RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L] # go directly to real files and directories RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] # respond to all other URLs by passing them through index.php RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # deny access if URL doesn't start with these RewriteCond %{REQUEST_URI} !^/(index\.php)?$ RewriteCond %{REQUEST_URI} !^/wp-[^/]+/ RewriteCond %{REQUEST_URI} !^/templates/ RewriteRule ^ - [L,F] </Directory> </VirtualHost>
原文:https://stackoverflow.com/questions/21418830
最满意答案
首先你不能让“QQmlListProperty”可写。 它只是一个特殊的对象,应该被视为QmlEngine写入的引用。
其次,您只能使用从QObject派生的类型,而QString则不能。
所有JSON对象都在内部由Javascript引擎保留,当有属性赋值时,转换为QVariant(数组具有类型QMetaType :: QVariantList,对象QMetaType :: QVariantMap)。
您应该只使用QVariant,QVariantList或QStringList。
The Qt docs have a sentence that indicates this can't be done:
Generally this constructor should not be used in production code, as a writable QList violates QML's memory management rules.
:(
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
自定义QML对象,其中包含可写的QString数组作为属性(Custom QML object with a writeable array of QString(s) as a property)[2022-05-05]
首先你不能让“QQmlListProperty”可写。 它只是一个特殊的对象,应该被视为QmlEngine写入的引用。 其次,您只能使用从QObject派生的类型,而QString则不能。 所有JSON对象都在内部由Javascript引擎保留,当有属性赋值时,转换为QVariant(数组具有类型QMetaType :: QVariantList,对象QMetaType :: QVariantMap)。 您应该只使用QVariant,QVariantList或QStringList。 The Qt docs ... -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
property Item someItem: Item { ... } 该项目不会成为父级,但仍会收集。 明确设置父级将确保它在相应的父级中可见。 请记住, Item::parent是可视父级,而不是实际父级。 因此,即使您明确设置了比属性持有者对象存活时间更长的父级,仍然会收集属性值对象。 这是因为与保持为null的可视父对象不同,“逻辑”父对象将被设置为属性持有者对象。 QML的内存管理是自动的,大多数部件都按预期工作。 要记住两件事: 内存管理器不太愿意释放内存,直到它变得非常必要 在一些“不太正 ...
-
你可以尝试像这样分配绑定: Component.onCompleted: Singleton.name = Qt.binding(function() { return qmlName }) 它适用于普通的QML对象,但不确定它是否适用于单例类。 无论如何,您可以在“从JavaScript创建属性绑定”一节中阅读有关此方法的更多信息。 You could try to assign the binding like this: Component.onCompleted: Singleton.name = ...
-
你有一个错字。 该标准将属性定义为writable ,不可writeable 。 修复b定义中的拼写,它完美地运行: b: { value: 'value configured, but writeable', writable: true } You have a typo. The standard defines the property as writable, not writeable. Fix the spelling in the b definition and it ...
-
我认为在C ++端进行连接并不合适,因为在编译时它不知道在QML中创建的信号,所以可能的解决方案是在QML端进行连接。 下面我将举例说明 main.cpp中 #include
#include #include #include class Test: public QObject{ QQuickView *view; Q_OBJECT public: Test(QObject *parent ... -
QML自定义属性(QML custom properties)[2021-12-02]
“不能将对象赋值给属性”,因为已经有了“data”这样的属性(它是只读的): http://qt-project.org/doc/qt-4.8/qml-item.html#data-prop "Cannot assign object to property" because there is already such property as "data" (and it's read-only): http://qt-project.org/doc/qt-4.8/qml-item.html#data-pr ... -
有关属性,可调用方法( 插槽 )和信号的所有信息都由QMetaObject存储在每个QObject中 。 如果您想列出对象中的所有属性: QObject *obj = findObjectMethod(); QMetaObject *meta = obj->metaObject(); int n = meta->propertyCount(); for(int i = 0; i < n; ++i) { qDebug() << "Property: " << meta->property(i)->name ...
-
首先,将StatedGuiElement创建为QQuickItem子类。 然后你创建一个StatedGuiElement.qml ,导入包含C ++元素的包,在里面创建一个StatedGuiElement {} ,在QML中添加你的状态,然后你就可以在你的项目中使用StatedGuiElement 。 它将是预定义QML额外内容的那个。 这假设元素实际上包含了您需要在C ++中实现的内容。 如果没有那么根本就没有C ++元素是没有意义的。 我不确定旧的C ++状态类是否可以与QML一起使用,可能不是,并且使 ...