简体   繁体   English

RewriteRule 重定向到完整网站 url (.htaccess)

[英]RewriteRule redirects to full website url (.htaccess)

I try to redirect my dynamic url to a static url. I almost achieved this goal.我尝试将我的动态 url 重定向到 static url。我几乎实现了这个目标。 But after opening the static url it will redirect to thefull path of my server.但在打开 static url 后,它将重定向到我的服务器的完整路径。 For example:例如:

Actual link (dynamic)实际链接(动态)

https://example.com/product?id=755&supermarket=albert-heijn&product=ah-roerbak-hollands-brocc-pomp-spitskool

desired link (static)所需链接(静态)

https://example.com/product/755/albert-heijn/ah-roerbak-hollands-brocc-pomp-spitskool

Result (static redirects to)结果(静态重定向到)

https://example.com/home/name/public_html/product/755/albert-heijn/ah-roerbak-hollands-brocc-pomp-spitskool/

My .htaccess is located inside my public_html folder, and there are no other .htaccess files on the server.我的 .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>

Try setting尝试设置

RewriteBase /

Or, if not works,或者,如果不起作用,

RewriteBase /home/name/public_html/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM