因此,此刻,所有丢失的页面(404)都会重定向到domain.com/search.php并带有查询参数
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ search.php [QSA,L]
这很好用,但是,对于domain.com/submit,我有一个极端的情况,我需要它重定向到domain.com/submit.php
似乎无法弄清楚该怎么做。
预先感谢
答案 0 :(得分:1)
像这样,我建议添加NC,因此不区分大小写:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^submit?$ submit.php [NC, L]
RewriteRule ^(.+)$ search.php [NC, QSA,L]
答案 1 :(得分:1)
您可以使用此:
RewriteEngine On
RewriteBase /
#rewrite /submit to /submit.php
RewriteRule ^submit/?$ submit.php [L,NC]
#rewrite other non-existent URIs to /search.pho
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ search.php [QSA,L]