我希望将目录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
答案 0 :(得分:2)
这是由于mod_dir
模块在真实目录前添加了一个尾部斜杠,并在重写规则之后进行了301重定向。
要解决这个问题:
DirectorySlash Off
RewriteEngine On
RewriteBase /public/
RewriteCond %{THE_REQUEST} /launcher\.php [NC]
RewriteRule ^ - [F]
#Remove the comments below to enable enforcing HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# add a trailing slash to directories
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^(.*?[^/])$ %{REQUEST_URI}/ [L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*?)/?$ launcher.php?urls=$1 [QSA,L]
答案 1 :(得分:0)
您的代码将变为:
#Options -Multiviews
RewriteEngine On
#Remove the comments below to enable enforcing HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /public
# Treat existing /core directory as non-existing (handled by launcher.php)
RewriteCond %{REQUEST_URI} ^/core(/.*)?$
RewriteRule . launcher.php [L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ launcher.php?urls=$1 [QSA,L]
RewriteRule . launcher.php [L]