0

I am trying to remove the .php extension from the url but i am out of luck trying a known solution that was given to me here on stack but i am in need of help. (Guide i followed) I have added needed RewriteConditions and rules to the .htaccess file and also updated my href to the following bellow but it will still not work. When i save the .htaccess file with the bellow values i get the error that the "page do not exist" when i try to access it.

.htaccess

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

RewriteCond %{REQUEST_URI} !^(.+)\.html$
RewriteCond %{REQUEST_URI} !^(.+)\.htm$
RewriteCond %{REQUEST_URI} !^(.+)\.php$
RewriteCond %{REQUEST_URI} !^(.+)\.js$
RewriteCond %{REQUEST_URI} !^(.+)\.css$
RewriteCond %{REQUEST_URI} !^(.+)\.jpg$
RewriteCond %{REQUEST_URI} !^(.+)\.png$
RewriteCond %{REQUEST_URI} !^(.+)\.gif$
RewriteCond %{REQUEST_URI} !^(.+)\.swf$
RewriteCond %{REQUEST_URI} !^(.+)\.xml$
RewriteCond %{REQUEST_URI} !^(.+)\.ico$
RewriteCond %{REQUEST_URI} !^(.+)\.txt$
RewriteCond %{REQUEST_URI} !^index\.html$
RewriteCond %{REQUEST_URI} !^index\.php$
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(.+)/$

change the href from register.php to register like this

<a href="register"><?php echo strtoupper(t('register', 'register')); ?></a>

The error i get when trying to access it is that the page do not exist.

  • How should we know? Which is your actual question? We have no idea about your setup, you have, but you did not tell us. So how should _we_ know? What is `echo strtoupper(t('register', 'register'));` ? We have no idea what that line does. Where did you code those two rewriting directives? What do you http server's log files say? What does your browser say? What is the result you receive back for requests? – arkascha Jan 11 '22 at 22:33

1 Answers1

0

try this :

RewriteRule ^(.*)$ $1.php

don't add any .php to your href attr.

Sajjad Sky
  • 81
  • 5
  • If the `RewriteRule` the OP posted apparently does not achieve to rewrite incoming requests, why do you think this `RewriteRule` will? – arkascha Jan 11 '22 at 22:34
  • Hi. I have updated my post and .htaccess contents as i missed a chunk of it that may cause a problem. – Klagor Mundavi Jan 11 '22 at 23:29