Forum Moderators: phranque

Message Too Old, No Replies

Main Site to Sub folder using .htaccess

Please Help

         

StarWolf

1:17 am on Dec 10, 2007 (gmt 0)

10+ Year Member



I have quite the pickle. I have looked everywhere for this, but to no avail. Their was post somewhere, but it was quite confusing.

I have looked at this post, but am confused as hell.

[webmasterworld.com...]

What I want to do is redirect http://www.example.net/cms to http://www.example.net/ using .htaccess without having the cms at the end. I have tried using a redirect form, but that only forwards it to that sub folder. I just want the sub folder in the root directory to be the main site's URL. I want the cms part gone when I go to http://www.example.net/ and have it go to the folder that I created "cms" in the root directory.

I have tried DirectoryIndex /cms/index.php which works the way I want it, but I tend to have problems when trying to go to other parts of the website. Meaning it redirects me to the main site and not to another folder, unless I type out the filename directly. Then it takes me straight there. Is their an easier way to figure this out?

Also will any command affect search engine crawling or other unknown things?

Please any help ASAP would be much appreciated!

[edited by: encyclo at 11:13 am (utc) on Dec. 10, 2007]
[edit reason] switched to example.com [/edit]

StarWolf

7:36 am on Dec 10, 2007 (gmt 0)

10+ Year Member



Well I somewhat got it working, but now it keeps thinking the directory is that.

DirectoryIndex index.htm
RewriteEngine on
RewriteRule ^index\.htm$ backup/gallery/index.php

It redirects just fine, but now I cannot keep the paths that it once had.

gergoe

2:03 pm on Dec 12, 2007 (gmt 0)

10+ Year Member



If you want to make the contents of the /cms/ directory look like as if it would be the root of your website (so when you go to http://www.example.com/ you actually want to see the content as you would go to http://www.example.com/cms/), then you are looking for the most common use of rewriting. There are many threads about this subject in this forum (I think every tenth post is about this, but with different phrasing and different names), but I'll give you a quick example how it should look like:


RewriteEngine On
Options +FollowSymLinks
RewriteBase /
# The following two lines will make sure files
# which are existing in the root are not rewritten,
# so if you have any files in your root, they will take
# precedence.
RewriteCond cms/%{SCRIPT_FILENAME}
!-f 
RewriteCond cms/%{SCRIPT_FILENAME}
!-d 
RewriteRule ^(.*)$ cms/$1 [L]

Besides of this, why not just copy the content of the cms directory into your root?

g1smd

1:32 am on Dec 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In the initial question you have refered, several times, to a redirect.

To be clear, what you actually need is a rewrite (as in the example posted).