我有喜歡的網址www.web.com/home,并www.web.com/about用.htaccess檔案:
RewriteEngine On
Options FollowSymLinks
ErrorDocument 404 http://www.web.com/page-not-found.html
RewriteRule "home" "index.php?c=home&m=main"
RewriteRule "about" "index.php?c=home&m=about"
如果我輸入類似www.web.com/asd,.htaccess將拋出404 error并直接page-not-found.html檔案
但是,如果我輸入www.web.com/homesssor www.web.com/about/a/b/c,.htaccess 則不會拋出404 error
我該如何解決?我使用純 PHP
uj5u.com熱心網友回復:
在重寫規則中使用元字符進行 1:1 匹配:
^ --- 匹配輸入的開頭
$ --- 匹配輸入的結尾
[L] --- 匹配后標記最后停止處理規則
RewriteEngine On
Options FollowSymLinks
ErrorDocument 404 http://www.web.com/page-not-found.html
RewriteRule ^home$ index.php?c=home&m=main [L]
RewriteRule ^about$ index.php?c=home&m=about [L]
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/350398.html
