Solved

htaccess Help rewrite  / redirection rules

Posted on 2012-03-27
7
256 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses

626 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