htaccess强制无扩展的作品

时间:2015-05-05 04:07:05

标签: php apache .htaccess mod-rewrite

https://admin.mydomain.com/log/general

该文件实际上是general.php

我在之前的服务器上使用以下.htaccess

# Remove file extension
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

它在我以前的服务器上工作,但不是我的新服务器,启用了mod重写,我确实在我的conf文件中添加了指令。当我输入

时,不确定为什么它不起作用
https://admin.mydomain.com/log/general

它没有加载general.php文件,它给我找不到404。 可能是我的mod重写错了吗?

这是我的根.htaccess内容

Order deny,allow

RewriteEngine On

# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://example.com/folder/$1 [R=301,L]

# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://example.com/folder/$1 [R=301,L]

# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]

Options -Indexes

DirectoryIndex index.php


Phpinfo()

Loaded Modules  core mod_so mod_watchdog http_core mod_log_config mod_logio mod_version mod_unixd mod_access_compat mod_alias mod_auth_basic mod_authn_core mod_authn_file mod_authz_core mod_authz_host mod_authz_user mod_autoindex mod_deflate mod_dir mod_env mod_filter mod_mime prefork mod_negotiation mod_php5 mod_rewrite mod_setenvif mod_socache_shmcb mod_ssl mod_status 

以下是我的apache2站点配置详情:

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin webmaster@localhost
                ServerName account.mydomain.com
                DocumentRoot /var/www/biz/admin
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                SSLEngine on
                SSLCertificateFile      /var/www/priv888.pem
                SSLCertificateKeyFile /var/www/priv888.key
                SSLCertificateChainFile /var/www/priv888.crt
                SSLCACertificateFile /var/www/priv888.ca-bundle


                <FilesMatch "\.(cgi|shtml|phtml|php)$">
                                SSLOptions +StdEnvVars
                </FilesMatch>
                <Directory /usr/lib/cgi-bin>
                                SSLOptions +StdEnvVars
                </Directory>
                BrowserMatch "MSIE [2-6]" \
                                nokeepalive ssl-unclean-shutdown \
                                downgrade-1.0 force-response-1.0
                BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
<Directory /var/www/biz/admin>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
 </Directory>

        </VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

感谢帮助

0 个答案:

没有答案