2014-02-13 46 views
0

我在ec2 redhat实例上运行Apache。我有https启用和工作,使用conf.d/ssl.conf。我正在尝试重写网址,以便用户不必添加.php扩展名。但是,由于某种原因,它不起作用。以下是我已经加入的ssl.conf:mod_rewrite不适用于https

<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> 

我得到一个404不带.php扩展,并能正常工作与扩展。

回答

0

那么,如果你想使用一个没有PHP扩展名的URL,但你希望它重定向到一个URL,可以这样试试你的重写规则。 这样,您就可以使用这样一个http://www.yoursite.com/somefile URL,它会重定向到http://www.yoursite.com/somefile.php

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