How to redirect default.php to /
I a开发者_如何学编程m trying to redirect default.php to / (path with no arguments) in Apache with .htaccess, but so far I have not find a way to make this work. If I do something like:
Redirect permanent /default.php powerkaraoke.com/
I get 500 error. Other redirects work fine, for example powerkaraoke.com->www.powerkaraoke.com.
What is the proper way of doing this? Thanks in advance for any help.
RewriteEngine on
RewriteRule ^default.php$ / [R=301,L]
I think that should work.
Redirect
requires an absolute path or absolute URL:
The new URL should be an absolute URL beginning with a scheme and hostname, but a URL-path beginning with a slash may also be used, in which case the scheme and hostname of the current server will be added.
But what you’ve provided is just a relative path. So try this:
Redirect permanent /default.php /
But as Redirect
just matches the given path prefix and adds remaining path segments (e.g. /default.php/foo/bar
gets redirected to /foo/bar
), you might want to use RedirectMatch
instead:
RedirectMatch permanent ^/default\.php$ /
精彩评论