我有一些用于 WordPress 网站的自定义 PHP 页面。我想通过 GET 方法使用具有几个变量的干净 URL。我已经搜索并尝试了我的 htaccess 代码的不同变体以及下面的 WordPress htaccess 代码,但没有成功。
我希望用户浏览和使用的 URL 是 www.thedomain.com/thefolder/details/123456/RES,而不是 www.thedomain.com/thefolder/details.php?mls=123456&ret=RES
我已将代码放在根目录的 htaccess 文件中。我也在 details.php 文件所在目录的 htaccess 中自己尝试过。
RewriteEngine On
## WordPress code
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./ /index.php [L]
## my code
RewriteBase /thefolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9]+)$ details.php?mls=$1&ret=$2
RewriteRule ^([a-zA-Z0-9]+)/$ details.php?mls=$1&ret=$2