My suggestion is to check if the "file" (being real or "virtual") is considered only in URL after Slash (/
), this because it would avoid conflicts with files with different names (it is a little difficult to detail the problem now), it should be something like:
RewriteEngine On
# Redireciona
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC,L]
# Reescreve
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(/|)$ $1.php [L]
The (.*)
takes the path and the (/|)
is to "ignore" the /
, this will help random access the URL like this:
That would cause this:
/pasta/public_html/foo/bar/.php
And this does not exist, if I understand you want /foo/bar
and /foo/bar/
(example urls) access /foo/bar.php
, the above code should solve, now chance does not work, try this (ps: I didn’t have time to test):
RewriteEngine On
# Redireciona
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC,L]
# Reescreve
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)([^/]+)(/|)$ $1$2.php [L]
If you have any POST form you send to .php
, that will fail:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC,L]
Because it will conflict the POST and the redirect, what you can do is a check, something like:
RewriteEngine On
# Redireciona
RewriteCond %{REQUEST_METHOD} !^(PUT|POST)$ [NC] #ignora o POST e PUT
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC,L]
# Reescreve
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)(/|)$ $1.php [L]
Still the best is to adjust your forms, take the .php
, thus:
<form class="m-t" role="form" method="post" action="validaacesso.php">
for
<form class="m-t" role="form" method="post" action="validaacesso">
On which of the friendly lines ?
– PauloMaia
I fixed the code. Replace the section below
##Internal Redirect
– Wallace Maxters
Okay, replace in ##Internal Redirect but now does not run any. Says ERR_TOO_MANY_REDIRECTS this page is not working , for all now !
– PauloMaia
It didn’t work because ?
– PauloMaia
@Would Paulomaia be able to check the Apache log? Because simply knowing it didn’t work doesn’t help much in identifying the problem.
– Wallace Maxters
@Paulomaia you must have mixed two Rewrites, it’s quite likely that yours . htaccess has more things, post on http://pastebin.com it complete and send the link here to Wallace analyze.
– Guilherme Nascimento
@Paulomaia trade the line for this
RewriteRule ^(.*)$ $1.php [L]
– Guilherme Nascimento
it is not generating error.log in folder
– PauloMaia
There is no other . htaccess in the /site/ === folder which is where all the files are.
– PauloMaia
@Guilherme Nascimento changed the line and in the same no page now access !
– PauloMaia
@Guilherme Nascimento === https://pastebin.com/vZzyLmBF
– PauloMaia
@Paulomaia so it’s giving problem, you mixed the code of Wallace with yours, it doesn’t make any sense to do.
– Guilherme Nascimento
@Guilherme Nascimento I changed and now does not remove the extensions . php no === https://pastebin.com/HQqsRyCN
– PauloMaia
@Paulomaia this and it has nothing to do with Wallace’s code, where is the
RewriteEngine On
?– Guilherme Nascimento
@Guilherme Nascimento === Same thing does not remove extensions no https://pastebin.com/fLNX8aWy
– PauloMaia
@Paulomaia I have no way to test, but make it work: https://pastebin.com/6uaj80dJ (let me know)
– Guilherme Nascimento
@Guilherme Nascimento === https://pastebin.com/6uaj80dJ === OK this now with the topic problem with those two url only they that do not work , and if I leave the system and try to login again does not find the user and password . not log tbm
– PauloMaia