[英]RewriteRule redirects to full website url (.htaccess)
我嘗試將我的動態 url 重定向到 static url。我幾乎實現了這個目標。 但在打開 static url 后,它將重定向到我的服務器的完整路徑。 例如:
實際鏈接(動態)
https://example.com/product?id=755&supermarket=albert-heijn&product=ah-roerbak-hollands-brocc-pomp-spitskool
所需鏈接(靜態)
https://example.com/product/755/albert-heijn/ah-roerbak-hollands-brocc-pomp-spitskool
結果(靜態重定向到)
https://example.com/home/name/public_html/product/755/albert-heijn/ah-roerbak-hollands-brocc-pomp-spitskool/
我的 .htaccess 位於我的 public_html 文件夾中,服務器上沒有其他 .htaccess 文件。
RewriteEngine on
# convert static url
RewriteRule /product/(.*)/(.*)/(.*)$ product.php?id=$1&supermarket=$2&name=$3
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
</IfModule>
嘗試設置
RewriteBase /
或者,如果不起作用,
RewriteBase /home/name/public_html/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.