Php .htaccess不允许子目录工作
这是.htaccess文件Php .htaccess不允许子目录工作,php,.htaccess,directory,Php,.htaccess,Directory,这是.htaccess文件 RewriteEngine on RewriteCond $1 !^(index\.html|index.php|administrator|system|template|js|lib|favicon\.ico|robots\.txt) RewriteRule ^(.*)$ /index.html?tpl=$1 [L] Options +FollowSymlinks 但是,下面的所有文件夹都不允许我进入它们并查看PHP文件 |administrator|sys
RewriteEngine on
RewriteCond $1 !^(index\.html|index.php|administrator|system|template|js|lib|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /index.html?tpl=$1 [L]
Options +FollowSymlinks
但是,下面的所有文件夹都不允许我进入它们并查看PHP文件
|administrator|system|template|js|lib
我认为,通过将文件放入RewriteCond
中,用户仍然可以进入http://example.com/news/happy
然后会转到index.php?tpl=etc等,但它阻止了我进入任何子目录,如
我不知道这是否适合你。但我要做的是添加这些规则,以加载对任何.php文件的调用,而不以.php结尾。你可以两者都打电话,不管有没有结尾 例如,您可以调用
my_url.com/myfolder/myfile
,它将加载带有友好url的myfile.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
我不知道这对你是否有用。但我要做的是添加这些规则,以加载对任何.php文件的调用,而不以.php结尾。你可以两者都打电话,不管有没有结尾 例如,您可以调用
my_url.com/myfolder/myfile
,它将加载带有友好url的myfile.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
我想建议你先读一下mod rewrite 1-把那条线放在最上面
Options +FollowSymlinks
该行要求您的服务器遵循符号链接,但我建议您使用更安全的选项“symlinksFownerMatch”
资料来源:
启用或禁用运行时重写引擎
资料来源:
给你。该规则要求web服务器添加重写条件以忽略正则表达式中列出的所有内容
我还为您添加了regex explain
!
不相上下
^
从
RewriteRule ^(.*)$ /index.html?tpl=$1 [L]
您要求将所有其他内容写入index.html?tpl=$1
**我想您是指index.php,我假设您不需要查询字符串
我想推荐使用更好的方法来处理这个问题
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(index\.html|index.php|administrator|system|template|js|lib|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /index.html?tpl=$1 [L]
我想建议你先读一下mod rewrite 1-把那条线放在最上面
Options +FollowSymlinks
该行要求您的服务器遵循符号链接,但我建议您使用更安全的选项“symlinksFownerMatch”
资料来源:
启用或禁用运行时重写引擎
资料来源:
给你。该规则要求web服务器添加重写条件以忽略正则表达式中列出的所有内容
我还为您添加了regex explain
!
不相上下
^
从
RewriteRule ^(.*)$ /index.html?tpl=$1 [L]
您要求将所有其他内容写入index.html?tpl=$1
**我想您是指index.php,我假设您不需要查询字符串
我想推荐使用更好的方法来处理这个问题
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(index\.html|index.php|administrator|system|template|js|lib|favicon\.ico|robots\.txt)
RewriteRule ^(.*)$ /index.html?tpl=$1 [L]
您是否检查了其他子目录中是否有其他使用其他规则的.htaccess文件?没有其他子目录有.htaccess。您是否检查了其他子目录中是否有其他使用其他规则的.htaccess文件?没有其他子目录有.htaccess。我是否将其放在sub directoryNop中。在根目录上,它应该可以正常工作。htaccess文件递归工作,除非有另一个文件可以替换这些规则。我是否将其放在sub directoryNop中。在根目录上,它应该可以正常工作。htaccess文件以递归方式工作,除非有另一个文件替代这些规则。