I have URLs in the form of example.com/pages/page1
and /example.com/pages/page2
Is there an easy way in .htaccess
to get rid of the /pages/
section, so my URLs are:
example.com/page1
Thanks
I have URLs in the form of example.com/pages/page1
and /example.com/pages/page2
Is there an easy way in .htaccess
to get rid of the /pages/
section, so my URLs are:
example.com/page1
Thanks
If you have the ability to modify the
DocumentRoot
, it sounds like you would just need to set yourDocumentRoot
to/path/to/pages
. However, if you can't do that then you can try this in.htaccess
The above is generic and redirects everything to
/pages
. If your pages really are called "page1 page2 etc", then this is more specific:Remove the
[L]
if you have more rewrite rules to process. The[QSA]
forwards along any other querystring parameters that may have been present.EDIT: For users to enter
example.com/pages/page1
to be redirected toexample.com/page1
:The above will redirect internally but not change the browser's address bar. If you want the address bar to change, informing the user that the redirect has happened, use
[L,R=301,QSA]
instead.