[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

.htaccess Redirect Question


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!
  • 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.
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

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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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