Reputation: 395
Inside public_html
directory I have a folder myfolder
and I have the index.php
in that folder.
All my site url reads
http://example.com/myfolder/page-name
I want it to rewritten as
http://example.com/page-name
What rule should I write in .htaccess
to achieve the same
Upvotes: 3
Views: 7062
Reputation: 15796
Here's what should work:
RewriteEngine On
RewriteRule /?myfolder/(.*) $1 [QSA,L]
The following sample does this: if we try to access something that doesn't start by /myfolder
, then add /myfolder
into the URL:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/myfolder
RewriteRule (.*) /myfolder/$1 [QSA,L]
Upvotes: 3
Reputation: 143906
In your public_html
directory's .htaccess
file, add these rules:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/myfolder
RewriteRule ^/?([^/]+)$ /myfolder/$1 [L]
Upvotes: 4