htaccess mod_rewrite help

nterror

New Member
Messages
112
Reaction score
0
Points
0
I have a couple websites on my server. Problem is that I can get to them by going to:

hostsite.tld/secondsite/

How do I redirect this to: secondsite.tld



Second, I don't want WWW on secondsite.tld. I Googled and tried many variations with no luck. If I go to the main page, it works. But if I go to something like this it does not:
http://www.secondsite.tld/page.html

I also have an open directory (secondsite.tld/public/)with its own htaccess with indexes enabled (as well as custom header/footer, the works), and adding any WWW removal rule gives me a 403 Forbidden error when trying to access the directory. Any ideas?

TIA
 

OdieusG

New Member
Messages
50
Reaction score
0
Points
0
These are JUST the pages you need! I looked into it, and it's good to use if you want a directory-like site

Code:
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
http://www.sitepoint.com/article/guide-url-rewriting/2/

The best to understand it would be the SitePoint link. That one tells your basics.....you might want to look into RegEx if you're going extensive, like:
Code:
http://mysite.com/2009/12/25
going to
Code:
http://mysite.com/date.php?yy=2009&m=12&d=25

But these should help a bit in the basics of mod_rewrite at least

And yes, I see I put Christmas down......:biggrin:
 

nterror

New Member
Messages
112
Reaction score
0
Points
0
I was able to fix the open directory by adding a + in front of Indexes.

And for some reason adding ifModule tags around mod_rewrite makes it work every time.
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
</IfModule>
Thanks for the links, I'm using those for the subdirectory redirect.
 
Last edited:
Top