Mobile app version of vmapp.org
Login or Join
Annie201

: 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

@Annie201

Posted in: #Htaccess #ModRewrite #UrlRewriting

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]

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Annie201

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme