.htaccess根据url重定向

.htaccess根据url重定向,.htaccess,.htaccess,在我的托管帐户中,我有域。一个位于根目录,另一个位于/example/文件夹中。这是我的main.htaccess文件中的重定向代码,除了我刚才描述的函数外,它还可以正常工作。此功能以前一直在工作,现在已神秘停止- Options -MultiViews RewriteEngine On RewriteBase / RewriteRule ^/example(.*)$ http://example.com/$1 [R=301,L] # Rewrite /example to http://ex

在我的托管帐户中,我有域。一个位于根目录,另一个位于/example/文件夹中。这是我的main.htaccess文件中的重定向代码,除了我刚才描述的函数外,它还可以正常工作。此功能以前一直在工作,现在已神秘停止-

Options -MultiViews
RewriteEngine On
RewriteBase /

RewriteRule ^/example(.*)$ http://example.com/$1 [R=301,L]
# Rewrite /example to http://example.com

# Remove .php from file names and force added slash
# http://stackoverflow.com/questions/1068595/htaccess-code-to-remove-extension-and-addforce-trailing-slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{THE_REQUEST} ^GET\ /[^?\s]+\.php
RewriteRule (.*)\.php$ /$1/ [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)/$ $1.php [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule .*[^/]$ $0/ [L,R=301]

有什么想法吗?

尝试删除前导斜杠,如下所示:

RewriteRule ^example(.*)$ http://example.com/$1 [R=301,L]

什么功能起作用?什么函数停止工作了?@OlafDietsche.htaccess文件的主要目的是重定向/about/to/about.php,这是可行的。将/example/to重定向到不起作用。哎呀,确实起作用了。我在/example/目录中有一个.htaccess文件覆盖了它。谢谢你的帮助!