: How to use .htaccess rewrite rules to remove .php and folders from URLs? I'm trying to simplify the URLs using rewrite condtions and rules on my local WAMP website. For example I would
I'm trying to simplify the URLs using rewrite condtions and rules on my local WAMP website. For example I would like to have /ProjetSyntheseFAC/mammiferes instead of /ProjetSyntheseFAC/pages/animaux/mammiferes.php.
I have to remove folders from the URL and delete the ".php" from the end.
Everything I've tried either does not work or produces an internal server error.
Here is my folder hierarchy:
/wwww/ProjectSyntheseFAC/:
- index.php
- .htaccess
- pages:
- animaux:
- mammiferes.php
- oiseaux.php
- reptiles.php
- infos:
- access.php
- contact.php
- plan.php
- spectacle:
- reserverPlace.php
- spectacle.php`
Here is what I tried last:
RewriteEngine On
RewriteRule ^mammiferes$ /pages/animaux/mammiferes.php
and
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} . [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{REQUEST_URI} /(.+)
RewriteRule !.[a-z0-4]{2,4}$ /pages/animaux/%1.php [NC,L]
RewriteRule (.*) /pages/animaux/ [L]
More posts by @Annie201
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.