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

x
?
Solved

htaccess Help rewrite  / redirection rules

Posted on 2012-03-27
7
Medium Priority
?
258 Views
Last Modified: 2012-04-17
Hi All

We have a simple html website hosted using a 3rd party hosting company.
we created a folder under the root website.

but when we type in

http://www.mywebsite.com.au/foldername it does not automatically redirect to http://www.mywebsite.com.au/foldername/ hence it gives us page not found error.

i was told by out web hosting company that this could be done via the htaccess

Could anyone please suggest what should i use for this purpose?
i tried redirect and rewrite rules but none seems to be working

my rewrite are as follows:

RewriteEngine on
RewriteRule ^/foldername$ foldername/ [NC,L]

is there anything missing here?
0
Comment
Question by:BCSITS
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:HAVARD7979
ID: 37777150
Why not use HTML redirect code:
<HTML>
<HEAD>
<meta http-equiv="refresh" content="2; URL=http://www.mywebsite.com.au/foldername">
</HEAD>
<BODY>
Waiting.........
</BODY>
</HTML>
Save as index.htm and upload to root dir

or for .htaccess

RedirectMatch permanent ^/$ http://www.mywebsite.com.au/foldername/index.htm

or

Redirect permanent / http://www.mywebsite.com.au/foldername
0
 

Author Comment

by:BCSITS
ID: 37779479
Hi All

Thanks for the suggestion.
However the html redirect suggestion. we wont be able to do because there is actually a main page in there called index.html that is hosting a running website.

my apologies for not mentioning this before but we actually have 2 folders
so for in this instance i would like to redirect

http://www.mywebsite.com.au/folder1 ===> http://www.mywebsite.com.au/folder1/
http://www.mywebsite.com.au/folder2 ===> http://www.mywebsite.com.au/folder2/

I tried .htaccess method using permanent and just Redirect, but none of it actually works.
The Redirect permanent gives us Internal Server Error 500 and the Redirect method does
not work aswell

Redirect permanent /folder1 http://www.mywebsite.com.au/folder1/
Redirect permanent /folder2 http://www.mywebsite.com.au/folder2/

Open in new window


Redirect /folder1 http://www.mywebsite.com.au/folder1/
Redirect /folder2 http://www.mywebsite.com.au/folder2/

Open in new window


Please help
0
 
LVL 6

Expert Comment

by:HAVARD7979
ID: 37781431
Who is your hosting company.  if they have cpanel you can set up a subdomain.  
it would be http://folder1.mywebsite.com.au instead of http://www.mywebsite.com.au/folder1 

even if you do not have a cpanel the hosting company should be able to set up the sub-domain for you.  I do this all the time where we have a regular website and a estore.  you an look at http://aaefe.org   and http://jle.aaefe.org     I think it looks better than the folder and if you are on linux server the folder name is case sensitive where the sub-domain is not.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

Author Comment

by:BCSITS
ID: 37784644
Hi HARVARD

Thanks for the info,

We are hosting through Melbourne IT
I know about the sub domain, but marketing specifically want to have
http://www.mywebsite.com.au/folder1 format not the sub domain.

I checked their console and asked their support they are not helpful at all.
they referred me to the htaccess and when I asked for assistance they send me the htaccess manual from Apache.org website.

Can someone help?
0
 
LVL 6

Expert Comment

by:HAVARD7979
ID: 37787320
the redirect should work have you tried

redirect http://www.mywebsite.com.au/folder1 http://www.mywebsite.com.au/folder1/

you need the full path on the first part.

I do not like them because Apache is famous for over writing the .htaccess on updates etc.
0
 
LVL 26

Accepted Solution

by:
arober11 earned 2000 total points
ID: 37848873
Hi

The issue with your original RewriteRule is that your using the httpd.conf rather than .htaccess syntax, a quick shuffle of a "/" and the following should work, in your .htaccess file:

RewriteEngine on
RewriteRule ^foldername$ /foldername/ [NC,L]
0
 

Author Comment

by:BCSITS
ID: 37849478
Hi Arober11

Thanks !!! that seems to have taken me one step closer.
but now when I type in

www.mywebsite.com/folder1

the rule seems to be taking out the "www" bit and it becomes

mywebsite.com/folder1/

how can i retain the www?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month8 days, 5 hours left to enroll

824 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