Reputation: 75
So I have a folder named pages which includes the pages for my site, when opening one of these files the url reads -
zebrafishweb/pages/contact
I would like it to just read
zebrafishweb/contact
I already have this htaccess file to remove any .php .html extensions which i would also like to carry on using. I don't have a clue how to write these htaccess files just copied it from the web and tailored it to me!
RewriteEngine on
RewriteRule ^(themes|order-now|submissions|faq|contact)$ $1.php [NC,L]
RewriteRule ^(home|faq)$ $1.html [NC,L]
Upvotes: 1
Views: 53
Reputation: 784898
/pages/
subdirectory with some rules for .php
and .html
extensions/contact
instead of /pages/contact
With those you can have your rules like this:
site root .htaccess
:
RewriteEngine On
RewriteRule ^contact/?$ pages/contact.php [L,NC]
pages/.htaccess
:
RewriteEngine On
# redirect to shorter URL
RewriteCond %{THE_REQUEST} /pages(/contact)[?\s]
RewriteRule ^ %1 [L,R=302]
# add .php to these files
RewriteRule ^(themes|order-now|submissions|faq|contact)/?$ $1.php [NC,L]
# add .html to these files
RewriteRule ^(home|faq)/?$ $1.html [NC,L]
Upvotes: 1