Reputation: 129
I have a directory called 'success-centers' (i dont want to go here)
I have a subdirectory called 'portal-pages/success-centers'
How do I ignore the first one but have my URL be:
local.com/success-centers/ OR local.com/success-centers/index.html through .htaccess?
this is my current htaccess file in the ROOT. it works fine but when I go to local.com/success-centers/ it goes to the directory that I do NOT want to go to.
Any help would be great. thanks.
RewriteEngine On
# add a trailing slash if portal-pages/$1 is a directory
RewriteCond %{DOCUMENT_ROOT}/portal-pages/$1 -d
RewriteRule ^(.*[^/])$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?!portal-pages/)(.*)$ portal-pages/$1 [L,NC]
Upvotes: 1
Views: 38
Reputation: 785128
Have it like this:
RewriteEngine On
# add a trailing slash if portal-pages/$1 is a directory
RewriteCond %{DOCUMENT_ROOT}/portal-pages/$1 -d
RewriteRule ^(.*[^/])$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!portal-pages/)(.*)$ portal-pages/$1 [L,NC]
There is no need to check for -f
or -d
as you want portal-pages/success-centers/
when URI in browser is /success-centers/
.
Upvotes: 1
Reputation: 29463
If I've understood your question correctly and you want the browser to point to a different page, but you don't want the URL of that different page to show up in the URL bar, you will need something along the lines of:
RewriteEngine On
RewriteRule ^success-centers(.*) /portal-pages/success-centers$1 [L]
Upvotes: 0