我想从
example.com
重定向到 example.com/home
。默认的 .haccess 文件是:
为什么下面的代码不起作用?
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit.
为了重定向到
home
路线,我将以下代码添加到.haccess
:
# Redirect to example.com/home
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ "http://example.com/home" [R=301,L]
</IfModule>
现在,.haccess 文件内容是
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit.
# Redirect to example.com/home
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{HTTP_HOST} ^example\.ir$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.ir$
RewriteRule ^(.*)$ "http://example.com/home" [R=301,L]
</IfModule>
但它不起作用,我遇到以下错误:
Internal Server Error 服务器遇到内部错误或 配置错误,无法完成您的请求。
如何从
example.com
重定向到 example.com/home
?
我在网上查了一下。并发现以下问题。但这是我的问题。 想要将 URL 从 www.domain.com/home 更改为 www.domain.com