Remove php extension on localhost apache server? -


i'm trying .php extension not required when view php file. current config following:

<virtualhost *:80>     documentroot /var/www/server     servername localhost      errorlog ${apache_log_dir}/error.log     customlog ${apache_log_dir}/access.log combined      rewriterule ^([^/\.]+)/?$ $1.php  [l,qsa]  </virtualhost> 

however, doesn't work i'm getting 404's when try access file login.php login, instance. server setup kind of strange, in /var/www/server symbolic link folder dev/server/. also, since it's localhost, i'm accessing via localhost/project/login.php.

you correct regex rule looks fail if uri contained periods in path. bad since rfc not not valid.

you try this:

rewriteengine on rewritecond %{request_filename} !-f rewriterule ([^\\.]+)$ $1.php [nc,l] 

that result in: http://test.com/test/test.test/test.php request http://test.com/test/test.test/test

i test more though. might want take @ .htaccess tester this: http://htaccess.madewithlove.be/

the request_filename can swapped out request_uri if needed in testing.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -