【发布时间】:2014-01-22 19:53:53
【问题描述】:
我使用 htacess 删除了 php 扩展名,它可以工作,但我还有一个名为 profile 的页面,我将其缩短,但这会使页面名称被视为配置文件用户名,有没有办法解决这个问题?
我想要的结果是这样的:
localhost/path_folder/index.php 到 localhost/path_folder/index
和
localhost/path_folder/profile?username=name 到 localhost/path_folder/name
我的 htaccess 删除扩展代码是:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC]
个人资料页面的代码是:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /path_folder/profile.php?username=$1
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite