[英]htaccess to remove .php and rename folder
我正在为本地项目使用php,我的网址如下:project.log / share / report1.php
我想从网址中删除.php,如果输入的网址包含.php,请将其删除,如果没有,就好像被发现了一样
共享文件夹,我也想将其显示为报告,反之亦然
到目前为止我取得的成就
RewriteEngine on
RewriteRule ^(.+)\.php$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [NC,END]
这样可以成功删除.php,但我不知道如何为共享文件夹添加表达式以替换其名称
您需要其他规则才能将share
重命名为reports
:
RewriteEngine on
RewriteRule ^share/(.*?)(\.php)?$ /reports/$1 [R=307,NC,L]
RewriteRule ^(.+)\.php$ /$1 [R=307,NC,L]
RewriteCond %{DOCUMENT_ROOT}/share/$1.php -f
RewriteRule ^reports/(.*)$ share/$1.php [END,NC]
RewriteRule ^reports/(.*)$ share/$1 [END,NC]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [NC,END]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.