Forum Moderators: phranque
http://www.mysite.com/forum/page.php I want to use this as the main index of my site, so people will see that page when they enter
http://www.mysite.com I also have a list of blogs located at
http://www.mysite.com/forum/weblogs.php I want people to see that list when they enter
http://www.mysite.com/blogs So by looking at what other people have done with mod_rewrite, i made this code;
RewriteCond %{HTTP_HOST} www\.mysite\.com
RewriteRule ^$ http://www.mysite.com/forum/page.php [L]
RewriteCond %{HTTP_HOST} www\.myhost\.com/blogs
RewriteRule ^([^.]+)$ weblogs.php [L] Will this work? If so, i just put this code somewhere in the .htaccess file in the public_html folder, right?
I'd really like to be sure before i try.
You may also want to make sure the rules will work with or without "www".
If you want to match a request for "blogs" then that has to be in your pattern.
With that in mind, I'd suggest:
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com
RewriteRule ^$ /forum/page.php [L]
RewriteCond %{HTTP_HOST} ^(www\.)?myhost\.com
RewriteRule ^blogs/?$ /forum/weblogs.php [L]
Will this affect any other pages in the /forum/ directory? For example, will /forum/index.php still function correctly?
Also, the weblogs.php list will be weblogs.php?dynamiccontent&user=x when you view a blog. Does that mean the url for the blog will be
http://www.mysite.com/blogs/?dynamiccontent&user=x? Thanks again for your help
Will this affect any other pages in the /forum/ directory? For example, will /forum/index.php still function correctly?Also, the weblogs.php list will be weblogs.php?dynamiccontent&user=x when you view a blog. Does that mean the url for the blog will be [mysite.com...]
You're asking me questions which I can't answer, because I don't know precisely how your site is set up. Realistically, the only way to find out is to test the code, either at a time when your server is least busy, or on a test server. If your site is always busy, then you should consider setting up a test server or creating a test subdomain on your existing server to help with situations like this.
You originally asked if your code was sound, and I pointed out a few syntax problems. Asking if your site will work with it goes well beyond the scope of a simple "Is this code OK?"-type question. So, I'm sorry, but I really don't know. :(
Jim
Here's the full .htaccess file
# -FrontPage-RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com
RewriteRule ^$ /forum/page.php [L]
RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com
RewriteRule ^blogs/?$ /forum/weblogs.php [L]
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.mysite.com
AuthUserFile /home/me/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/me/public_html/_vti_pvt/service.grp
And i put it in the public_html folder
Jim