【发布时间】:2020-05-13 23:16:55
【问题描述】:
你好,我有个小问题。
当使用.htaccess这几行时
RewriteEngine on
Options +FollowSymLinks
# clean up file extensions .php only
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
#make get request clean
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^cms/tests/([0-9]+) cms/tests/index.php?survey=$1 [NC,L]
我转换网址
cms/tests/index.php?survey=65 到 -> cms/tests/65
这行得通!
现在我想要一个这样的编辑模式:
cms/tests/65/edit 或 cms/tests/65/view
这是我想出的重写规则:
RewriteEngine on
Options +FollowSymLinks
# clean up file extensions .php only
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
#make get request clean
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^cms/tests/([0-9]+)/([a-zA-Z0-9_-]+) cms/tests/index.php?survey=$1&mode=$2 [NC,L]
像 cms/tests/index.php?survey=65&mode=edit 这样编写完整的网址时,它完全可以工作
但它带有“干净”的 url,它会转到我的 404 页面,并在网络选项卡中显示 302 重定向。
有什么我做错了或看多了?
【问题讨论】: