Solved

.htaccess Redirect Question

Posted on 2012-04-13
4
187 Views
Last Modified: 2012-04-16
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
Comment
Question by:PaliTree
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Anuroopsundd
ID: 37843062
0
 

Author Comment

by:PaliTree
ID: 37843177
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
 
LVL 26

Accepted Solution

by:
arober11 earned 250 total points
ID: 37848601
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
 

Author Comment

by:PaliTree
ID: 37850460
Many thanks arober11! I've used the "DirectoryIndex" solution.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question