Solved

htaccess Help rewrite  / redirection rules

Posted on 2012-03-27
7
248 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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

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 500 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now