.htaccess 301 rediect going to root


.htaccess 301 rediect going to root

>我正在尝试使用 .htaccess 301 重定向,但它不起作用

我在我的 .htaccess 文件中使用以下语法

RewriteRule ^our_services.html http://localhost/site/our-services [R=301,L]

但是当我打开页面页面时,重定向到

http://localhost/Applications/XAMPP/xamppfiles/htdocs/site/our-services

如何写正确的一个?

我想重定向

our_services.html to our-services

在同一域中

谢谢

您可以尝试这样的相对路径吗:

如果在DOCUMENT_ROOT

RewriteEngine On
RewriteBase /
RewriteRule ^our_services'.html$ /our-services [R=301,L,NC]

如果在DOCUMENT_ROOT/site

RewriteEngine On
RewriteBase /site/
RewriteRule ^our_services'.html$ our-services [R=301,L,NC]