Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

.htaccess Redirect Question

Greetings

I have a folder on my web site - let's call it /docs.

I need to be able to redirect requests "permanently" for "http://mydomain.com/docs/" to "http://mydomain.com/docs/special-page.html". But I don't want it to effect requests for other pages in that folder e.g. "http://mydomain.com/docs/page1.html" etc

I tried:
redirect 301 /docs/ http://mydomain.com/docs/special-page.html
But that DID seem to mess up access to the other pages!
0
PaliTree
Asked:
PaliTree
  • 2
1 Solution
 
PaliTreeAuthor Commented:
Anuroopsundd - that's a link, not an answer. Note: I am NOT redirecting to another folder. I am redirecting requests for the folder (/docs/) to a file within that folder.

To repeat: redirect 301 /docs/ http://mydomain.com/docs/special-page.html does not seem to work.
0
 
arober11Commented:
You don't need a redirect; easiest solution would be to rename special-page.html  to index.html. This should result in the page being served when q request for the /docs/ directory turn's up.

Alternatively you could add special-page.html to the DirectoryIndex directory in either the httpd.conf or .htaccess file e.g.

DirectoryIndex index.html special-page.html

Open in new window


to achieve the same result.

Or you could add a rewrite rule along the following lines:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*   http://mydomain.com/docs/special-page.html  [L,R=301]

Open in new window

0
 
PaliTreeAuthor Commented:
Many thanks arober11! I've used the "DirectoryIndex" solution.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now