【发布时间】:2026-01-06 05:00:02
【问题描述】:
我目前在我的 htaccess 中有以下内容,无需用户在每个页面后都有 '.php' - 例如转到 URL.com/about 与 URL.com/about.php 的工作方式相同:
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
我还有一个交易页面,其中 URL 中有两个变量:
URL.com/deals?make=samsung&model=X500D
我想要完成的是通过以下方式访问上述网址:
URL.com/samsung-X500D/(尾随窗扇是可选的)
我已尝试将以下内容添加到顶部的现有 htaccess 代码中,但我收到 500 服务器错误代码:
RewriteRule ^([^-]*)-([^-]*)$ /deals?make=$1&model=$2 [L]
我也不需要重写页面上的任何 css / img 文件 - 这只是我想要更改的 URL。
【问题讨论】:
-
欢迎来到 Stack Overflow!一般来说,这里同意you shouldn't use greetings or salutations in your posts。它们妨碍了我们读者弄清楚实际问题。这次我已经为你编辑了。
标签: .htaccess mod-rewrite url-rewriting cpanel