apache - .htaccess rewrite to add .php to no extension requests, BUT to not accept .php requests by users -


i want rewrite rules (mod_rewrite) block users accessing pages directly, using .php extension @ end of urls, want keep php files extension in website folders. problem , want server accept no extension url requests, , take user respective .php page. have following rewrite code:

rewriteengine on rewriterule \.php$ - [r=404] rewriterule ^(.*)$ $1.php 

the first rule giving 404 error, wanted. second rule works when it's alone, no other rules. above block, when type no extension url think server "redirecting" request , adding .php extension, first rule act user request , give me 404 error, making 2nd not work want.

i think need rewrite condition tell server apply first rule if request comes website user, , ignore if comes rewrite engine. possible?

i not htaccess guru yet, hope helps:

rewritecond %{the_request} \.php rewriterule \.php$ - [r=404]  rewritecond %{request_uri} !(\.php) rewritecond %{request_uri} !(^\/error\/.*$) rewriterule ^(.*)$ $1.php [l] 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -