apache - mod_rewrite enabled, rewrite Engine is on but file does not load without .php extention -
i using apache 2.4 httpd server running php 5.6
i have enabled mod_rewrite in httpd.conf
folder removing comment on: loadmodule rewrite_module modules/mod_rewrite.so
i have added .htaccess file server directory , virtual host directory.
the server directory in httpd.conf
file , looks this:
documentroot "c:/web" <directory "c:/web"> directoryindex index.html index.php options indexes followsymlinks allowoverride require granted allow </directory>
in httpd-vhosts.conf
have following:
servername localhost documentroot "c:\web" <virtualhost *:80> <directory "c:\web"> options indexes followsymlinks multiviews includes execcgi allowoverride order allow,deny allow require granted </directory> servername localhost serveralias localhost documentroot "c:\web" </virtualhost> <virtualhost *:80> servername personal.localhost serveralias personal.localhost documentroot "c:\personal\web" directoryindex index.html index.php <directory "c:\personal\web"> options indexes followsymlinks multiviews includes execcgi allowoverride order allow,deny allow require granted </directory> </virtualhost>
i know apache server loads .htaccess
file because if add broken code file 500 internal server error
(it when broken code @ top or bottom of page.)
my .htaccess
file looks this:
indexignore * # prevent directory listing order deny,allow allow * # ------------------------------------------ # hide php extentions rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ $1.php [l] # ------------------------------------------ # should set cache items <ifmodule mod_headers.c> <filesmatch "\.(jpg|jpeg|png|gif|swf|mp3|avi|js|css|html|php)$"> header set cache-control "max-age=604800, public" </filesmatch> </ifmodule> # ------------------------------------------ # compress data <ifmodule mod_gzip.c> mod_gzip_on yes mod_gzip_dechunk yes mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^content-encoding:.*gzip.* </ifmodule>
in access.log
file can see request doesn't add .php
extention end of url:
developerusr - - [27/jan/2016:15:12:44 +0200] "get /admin/login http/1.1" 404 209
and error.log
file has following: [wed jan 27 15:12:44.324658 2016] [negotiation:error] [pid 18324:tid 1084] [client ::1:50784] ah00687: negotiation: discovered file(s) matching request: c:/personal/web/admin/login (none negotiated).
what can enable .htaccess
or url rewrite. know .htaccess
file works because if load server linux production environment loads , works. don't have access config files production environment, can't see wrong config files.
disable multiviews if you're relying on mod_rewrite map in way.
Comments
Post a Comment