Apache 使用.htaccess定向到登录页
我目前正在.htaccess中使用此选项从我的URL中删除“index.php”:Apache 使用.htaccess定向到登录页,apache,.htaccess,Apache,.htaccess,我目前正在.htaccess中使用此选项从我的URL中删除“index.php”: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php [L] 但我还想将主页(即example.com)重定向到临时登录页。因此,example.com应该指向landing.html,但是我的应用程序的任何页面,即运行index.ph
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [L]
但我还想将主页(即example.com)重定向到临时登录页。因此,example.com应该指向landing.html,但是我的应用程序的任何页面,即运行index.php的页面,都需要不受影响。我试过:
RewriteRule / landing.html [L,R=302]
及
但由于某种原因,它会弄乱CSS和相关路径。有人能帮忙吗
我的httpd.conf中的DocumentRoot是/var/www/html/example.com/current,此目录“/current”设置为AllowOverride All,而/var/www/html/example.com设置为AllowOverride None找到了解决方案:
RedirectMatch 301 ^/$ /landing.html
找到解决方案:
RedirectMatch 301 ^/$ /landing.html
@乌尔里希帕拉;它增加了噪音,并且已经存在一种将问题标记为已解决的机制。@UlrichPalha;它增加了噪音,并且已经存在一种机制,可以将问题标记为已解决。+1用于自己解决问题。尽管要注意,RedirectMatch是来自mod_alias的指令,而不是mod_rewrite。mod_rewrite实现这一点的方法:RewriteRule^?:$| index\.php/landing.html[R,L]+1自己解决。尽管要注意,RedirectMatch是来自mod_alias的指令,而不是mod_rewrite。mod_rewrite的方法是:RewriteRule^?:$| index\.php/landing.html[R,L]