Reputation: 316
I was successfully able to change my .htaccess
file to change the url to my website files, removing the access
folder.
SITEMAP
index.php
/access
-dashboard.php
-posts.php
-account.php
Old URL : mywebsite.com/access/dashboard.php
New URL: mywebsite.com/dashboard.php
This is all working perfectly, the only issue is that, I can still access my files from the old url. I would like to redirect that url to the new one so that it is not used anymore. How can I do this?
Here is my current .htaccess
file:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/access/$1.php -f
RewriteRule ^(.+?)/?$ access/$1.php [L,NC]
Upvotes: 2
Views: 45
Reputation: 784918
Insert this rule just below RewriteBase /
line:
RewriteCond %{THE_REQUEST} \s/+access/(\S*) [NC]
RewriteRule ^ /%1 [R=301,L,NE]
This will match /access/<anything>
from raw Apache request and redirect to a URL without /access
.
Upvotes: 2