[英]htaccess redirect query is not loading page
我無法使它正常工作。 我想要
http://localhost/test/post.php?id=15
顯示
http://localhost/test/post/15
我的嘗試加載了一個沒有CSS的頁面,並向我顯示了我的客戶404錯誤頁面
Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/
ErrorDocument 404 /errors/404.php
RewriteCond %{QUERY_STRING} ^id=(.+)$ [NC]
RewriteRule ^post\.php post/%1? [R,L]
請幫幫我!
為此,您將需要%{THE_REQUEST}
變量。 THE_REQUEST
變量表示Apache從您的瀏覽器收到的原始請求,在執行某些重寫規則后不會被覆蓋。 此變量的示例值為GET /index.php?id=123 HTTP/1.1
。
您的代碼將是:
ErrorDocument 404 /errors/404.php
Options -Indexes -MultiViews +FollowSymlinks
RewriteEngine On
RewriteBase /test/
RewriteCond %{THE_REQUEST} /post\.php\?id=([^\s&]+) [NC]
RewriteRule ^ post/%1? [R=302,L]
RewriteRule ^post/([^/.]+)/?$ post.php?id=$1 [L,QSA,NC]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.