获取参数和.htaccess - 奇怪的URL

时间:2017-08-10 19:12:50

标签: php .htaccess

我的.htaccess重写规则存在问题。

RewriteEngine On

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-zA-Z0-9-]+)/(.*)$ /other-app/application/$2&THEME=$1 [L]

我需要网址:

localhost:8443/other-app/application/nice-url-theme/index.php
localhost:8443/other-app/application/nice-url-theme/edit.php?edit&EDIT_ID=XX
localhost:8443/other-app/application/nice-url-theme/brow.php
localhost:8443/other-app/application/nice-url-theme/brow.phpPARAM1=XX&PARAM2=YY

如果我收到网址

localhost:8443/other-app/application/nice-url-theme/edit.php?edit&EDIT_ID=XX

显示错误 404:other-app / application / edit.php& THEME = nice-url-theme not found。

参数星的问题在哪里?为什么它不能采用GET参数?

1 个答案:

答案 0 :(得分:1)

您可以使用此规则:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([a-z0-9-]+)/(.*)$ /other-app/application/$2?THEME=$1 [L,NC,QSA]
  • ?代替&正确形成查询字符串
  • QSA用于保留现有查询字符串。