Reputation: 925
I've made a web app, and left all of the pages (.php) in the root of the project folder. I now want to move every page from the project root folder into a /view folder.
Original URL Example: project/about-us
Original File: project/about-us.php
Desired URL: project/about-us
Original File Location: project/views/about-us.php
I have tried Hiding folder in URL using .htaccess but no luck as of yet.
My .htaccess already has the below rules to handle file extensions and caching.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
Any advice would be appreciated.
Update: File Structure
Upvotes: 1
Views: 622
Reputation: 10549
If you want a specific url to load a specific file:
RewriteRule ^about-us(|/)$ views/about-us.php [L]
Upvotes: 1