how can hide .php suffix

lsfoo

Administrator
#3
Hi Seyed,

Apologies for the delay, I just wanted to verify that the fix works.

First, enable rewrite rules for the virtual host. Then, try these rewrite rules:

Code:
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ $1 [R,L]

RewriteCond %{REQUEST_URI} !(\..*|/)$
RewriteRule ^(.*)$ $1.php [L]
The first rule will redirect requests that end in .php to extension-less urls. The second rule will take all extensionless (and non '/' requests) and append .php to it so that the request will be handled by the php engine.

I only tested this a few times, so it may block some other types of requests, so I recommend you try all the possible types of requests you may encounter.

Please let me know how it goes,
Kevin
 
#4
Hi Seyed,

Apologies for the delay, I just wanted to verify that the fix works.

First, enable rewrite rules for the virtual host. Then, try these rewrite rules:

Code:
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ $1 [R,L]

RewriteCond %{REQUEST_URI} !(\..*|/)$
RewriteRule ^(.*)$ $1.php [L]
The first rule will redirect requests that end in .php to extension-less urls. The second rule will take all extensionless (and non '/' requests) and append .php to it so that the request will be handled by the php engine.

I only tested this a few times, so it may block some other types of requests, so I recommend you try all the possible types of requests you may encounter.

Please let me know how it goes,
Kevin
a lot of thanks
it works sooooo good :)
 
Top