我已經學習並編寫了一些.htaccess
規則,有些正在執行完美。但也有一些是沒有得到執行,並顯示錯誤或404
在特定的URL重寫規則中獲取404
這些規則
RewriteEngine on
# index.php?store=xyz (executing perfectly)
RewriteCond %{QUERY_STRING} store=([^&]+)&?
RewriteRule /?index.php$ /%1 [END,R=301]
RewriteRule ^/?([a-zA-Z0-9]+)$ index.php?store=$1 [END]
RewriteRule ^/?([a-zA-Z0-9]+)/products$ index.php?store=$1&view=products [END]
RewriteRule ^/?([a-zA-Z0-9]+)/products/([0-9]+)$ index.php?store=$1&view=products&category=$2 [END]
RewriteRule ^/?([a-zA-Z0-9]+)/products/([0-9]+)$ index.php?store=$1&view=sales&sale=$2 [END]
RewriteRule ^/?([a-zA-Z0-9]+)/single/([0-9]+)$ index.php?store=$1&view=single&product=$2 [END]
# index.php?store=xyz&view=products(executing perfectly)
RewriteCond %{QUERY_STRING} store=([^&]+)&?
RewriteCond %{QUERY_STRING} view=products&?
RewriteRule /?index.php$ /%1/products [END,R=301]
# index.php?store=xyz&view=products&category=123(executing perfectly)
RewriteCond %{QUERY_STRING} store=([^&]+)&?
RewriteCond %{QUERY_STRING} view=products&?
RewriteCond %{QUERY_STRING} category=([^&]+)&?
RewriteRule /?index.php$ /%1/products/%3 [END,R=301]
# index.php?store=xyz&view=sales (error 404)
RewriteCond %{QUERY_STRING} store=([^&]+)&?
RewriteCond %{QUERY_STRING} view=sales&?
RewriteRule /?index.php$ /%1/sales [END,R=301]
# index.php?store=xyz&view=sales&sale=123 (error 404)
RewriteCond %{QUERY_STRING} store=([^&]+)&?
RewriteCond %{QUERY_STRING} view=sales&?
RewriteCond %{QUERY_STRING} sale=([^&]+)&?
RewriteRule /?index.php$ /%1/sales/%3 [END,R=301]
# index.php?store=xyz&view=single&product=123(executing perfectly)
RewriteCond %{QUERY_STRING} store=([^&]+)&?
RewriteCond %{QUERY_STRING} view=single&?
RewriteCond %{QUERY_STRING} product=([^&]+)&?
RewriteRule /?index.php$ /%1/single/%3 [END,R=301]
能否請你告訴我,我可能做錯了什麼?
查看代碼!我寫了'(完美執行)'和'(錯誤404)',它們的規則寫在下面 –