mod_rewrite不适用于https

时间:2014-02-13 18:07:43

标签: apache mod-rewrite

我在ec2 redhat实例上运行Apache。我使用conf.d / ssl.conf启用了https并正常工作。我试图重写网址,以便用户不必添加.php扩展名。但是,由于某种原因,它不起作用。这是我添加到ssl.conf的内容:

<VirtualHost _default_:443>

# General setup for the virtual host, inherited from global configuration
DocumentRoot "/var/www/https-html"

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

.
.
.

</VirtualHost>

我得到一个没有.php扩展名的404,它可以与扩展名一起使用。

1 个答案:

答案 0 :(得分:0)

好吧,如果你想使用一个没有php扩展名但你希望它重定向到一个的URL,那就试试你的重写规则吧。 这样您就可以使用此http://www.yoursite.com/somefile之类的网址,并将其重定向到http://www.yoursite.com/somefile.php

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