htaccess Help rewrite / redirection rules

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?
BCSITSAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
arober11Connect With a Mentor Commented:
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
 
HAVARD7979Commented:
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
 
BCSITSAuthor Commented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
HAVARD7979Commented:
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
 
BCSITSAuthor Commented:
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
 
HAVARD7979Commented:
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
 
BCSITSAuthor Commented:
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
All Courses

From novice to tech pro — start learning today.