[英]How can hide directory name from the url using htaccess?
For example I have url like http://localhost/Experiments/login/login.php例如我有像http://localhost/Experiments/login/login.php这样的网址
I have hide the extention of file putting below code in .htaccess file我在 .htaccess 文件中隐藏了以下代码的文件扩展名
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME}\.png -f
RewriteRule ^(.*)$ $1.png
RewriteCond %{REQUEST_FILENAME}\.css -f
RewriteRule ^(.*)$ $1.css
RewriteCond %{REQUEST_FILENAME}\.js -f
RewriteRule ^(.*)$ $1.js
RewriteCond %{REQUEST_FILENAME}\.jpg -f
RewriteRule ^(.*)$ $1.jpg
RewriteCond %{REQUEST_FILENAME}\.ico -f
RewriteRule ^(.*)$ $1.ico
how can I make the above url to http://localhost/login Even I tried for the solutions related to the same issue in stackoverflow but could not make it如何将上述 url 设为http://localhost/login即使我尝试过与 stackoverflow 中相同问题相关的解决方案,但无法实现
Insert this rule just below RewriteEngine On
line :在
RewriteEngine On
line 下方插入此规则:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/Experiments/login/$1.php -f
RewriteRule ^([\w-]+)/?$ Experiments/login/$1.php [L]
# remaining rules go below this
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.