【发布时间】:2020-04-13 18:34:50
【问题描述】:
我已经尝试了在这里能找到的所有东西。也许是我的 wamp 配置,或者该网站不在 root 中,我不知道。基本上有些东西有用有些没用。
我想要实现的是完全删除 index.php 和所有 .php 扩展名,并在末尾强制添加斜杠 /。
我还想在第二个“/”之后传递一个 GET 参数。
举例
localhost/index.php -> localhost/
localhost/search.php -> localhost/search/
localhost/search.php?d=1 -> localhost/search/1/
我的 httpd-vhosts.conf :
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
RewriteEngine On
RewriteRule ^/?payday/$ /index.php [END]
RewriteRule ^/?payday/(\w)/?$ /$1.php [END]
RewriteRule ^/?payday/(\w)/([^/])/?$ /$1.php?param=$2 [END]
</Directory>
</VirtualHost>
我的 .htaccess :
RewriteEngine On
RewriteRule ^/?payday/$ /index.php [END]
RewriteRule ^/?payday/(\w)/?$ /$1.php [END]
RewriteRule ^/?payday/(\w)/([^/])/?$ /$1.php?param=$2 [END]
【问题讨论】:
标签: php .htaccess url get wamp