【发布时间】:2016-04-10 04:25:07
【问题描述】:
我希望将目录 www.example.com/core 转换为字符串,而不是仅仅禁止访问它。这可能吗?
更新(仍然没有运气):
我当前的 .htaccess
#Options -Multiviews
RewriteEngine On
#Remove the comments below to enable enforcing HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Handle Front Controller...
RewriteBase /public
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ launcher.php?urls=$1 [QSA,L]
RewriteRule . launcher.php [L]
这里有一些场景:
我写了一个网址www.example.com/some-dir-that-does-not-exist,效果很好。
我写了一个网址www.example.com/url-that-DOES-exist,浏览器将其重定向到www.example.com/url-that-DOES-exist/?url=url-that-DOES-exist
【问题讨论】:
-
你能说得更清楚些吗?我的意思是如果我 GET 服务器会响应 |发布 |头 |任何请求
http://www.example.com/core? -
我不是在谈论不存在的目录。那些我没有问题的。但是,如果我希望将确实存在的目录视为不存在的目录。现在,如果我写 www.example.com/core,浏览器会转到 www.example.com/core/?url=core
-
我不确定这是否是您想要实现的目标。如果你添加这条规则
RewriteRule ^/core(/.*)?$ - [R=404,L],它会做你想要的吗?我不太明白要翻译成字符串的部分 -
它仍然重定向到
/core/?url=core,现在添加了一个 500 错误 -
您希望将现有目录视为不存在的目录吗?
标签: regex apache .htaccess mod-rewrite directory