Forum Moderators: phranque
It seems that whenever you have
Rewrite Engine On
in your .htaccess, and FPSE are enabled, a 403 error is produced after you submit a form (the form never gets submitted).
The only place I have found that gives a working solution, is found here: [msfrontpage.net...]
However that solution doesn't seem to work, and many articles on the site are outdated. (The author dicusses background fixes for NS 3/4 in one of his posts :P )
The looping that we usually discuss here can occur in .htaccess due to the fact that any rewritten URL must be passed back through httpd.conf and then through .htaccess files in the new directory path, in order to check for more rewrites and access restrictions -- otherwise, .htaccess could be used to circumvent access restrictions - a major security problem. Therefore, .htaccess code must be coded as if it were 're-entrant' or 'recursive' to avoid loops. That doesn't usually apply to httpd.conf, because it doesn't reinvoke itself.
Jim
> Ok, but that still would not work, even if it didn't produce the looping error.
I don't understand. Why do you think it won't work?
--
chopin2256,
You can use mod_alias directives (Redirect or RedirectMatch) in a <VirtualHost> container in httpd.conf. In .htaccess, mod_rewrite is the only module that has the capability of selectively redirecting based on the requested hostname. In httpd.conf, the redirect is conditional upon the <VirtualHost> container, so it will redirect only www- or non-www as specified by the container.
Jim
I don't understand. Why do you think it won't work?
[edited by: engine at 11:17 am (utc) on Aug. 26, 2005]
Especially if you have the option to do the rewrites in httpd.conf
I am on a shared server right now. I couldn't find the httpd.conf file. Is it located here?
/etc/httpd/conf/httpd.conf
If so, I did not see it. Would changing to a virtual hosting account grant me this freedom, because it looks like I may have to do this now.
'Unexpected' looping is only a problem in .htaccess, because of the way .htaccess files are processed as described above. With very slight modifications, mod_rewrite code will work in httpd.conf. Or you can use Redirect or RedirectMatch in a <VirtualHost> container or other container to make them conditional .. i.e. only redirect requests for the 'incorrect' domain name.
I'm not sure what you put in your .htaccess this time, but Apache directives are restricted in their use; The documentation for each directive tells you where it can be used. So, if you tried to put a <VirtualHost> or <Directory> container into .htaccess, that would fail with a 500 Server Error. If you tried to use a Redirect directive without making it conditional by enclosing it in a container, then it would loop.
Jim
<VirtualHost www.example.com>
ServerName www.example.com
..the rest
</VirtualHost>
<VirtualHost *>
Redirect 301 / http://www.example.com/
</VirtualHost>
At least if you add a <base href> definition in your page headers, all in-site links on the page will appear with www whether or not the page was opened with www, ie: <base href="http://www.example.com">.
If you are using the redirecting code...this is what you use in the htaccess file directly under the www folder:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Then replace:
"Options None" with "Options +FollowSymLinks" in every single htaccess file that you can find. There will only be about 7 of these files according to the subdirectories I listed below. Here are some subdirectories where they may be found:
_vti_bin (_vti_adm, _vti_aut)
_vti_cnf
_vti_log
_vti_pvt
_vti_txt
Remember, if you replace the Options None with Options +FollowSymLinks in every single one of these htaccess files, you should be able to connect to the server with Frontpage.
Again, thanks goes to Bumpski for bringing this to my attention.
Hope this helps others having the same problem.
RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteCond %{http_host} ^(example+\.com) [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
I used to use the code chopin has above, but just went an did it with
RewriteCond %{http_host} ^(example+\.com) [NC]
instead of
RewriteCond %{HTTP_HOST} ^example\.com [NC]
Any downside in what I used? It does work with the parentheses, but I'm clueless about this stuff so if someone who understands this stuff, even if they don't know frontpage, could comment about the sense of that specific code in .htaccess, that would be cool.
(Also, I only altered the None in _vti_bin (_vti_adm, _vti_aut) not any of the others, and FP and the redirect worked.)
Btw, if you look at my first post, I link over to [msfrontpage.net...]
which discusses the fix, but it didn't seem to work for me.
A correct-case and minimalist solution would be written:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Parentheses are only needed to
1) create a back-reference
2) enclose a list of alternates: ^(abc¦def¦ghi)$
3) enclose an optional substring: ^(www\.)?example\.com
I'd appreciate it if everyone who's had problems with mod_rewrite and Frontpage Extensions would post back here and let us know if this solution fixes your problem. It seems there's little info on the Web about it, and the problem seems to be widespread.
Jim
Simply add Options +FollowSymLinks to your main .htaccess file, then each FrontPage created folder's .htaccess file needs Option None changed to Options +FollowSymLinks.
There are quite a few needed to be changed, I found more than 7.
The Frontpage publishing and Deep Throat mysteries revealed in the same month. Who would have thunk it...
Anyway, I just switched to:
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
And it worked with no problems. Again, I only also made the +FollowSymLinks change to the _vti_bin and its two subfolders, not all the Frontpage underscore folders.
Also, in addition to the www redirect, I have code in .htaccess to prevent hotlinking, and having that additional code doesn't create a problem with this fix in place.
Finally, is their a brief answer for what "+FollowSymLinks" means? I mean, follow the links from directoryies, okay, but what does it mean in this context?
I'm not sure if mod_rewrite actually requires SymLinks, or if they are simply considered to have very similar "security" effects, and therefore arrangements were made to share the on/off controls.
Jim
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
#The next line modified by DenyIP
order allow,deny
#The next line modified by DenyIP
#deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.example.com
AuthUserFile /home/example/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/example/public_html/_vti_pvt/service.grp
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from nn.nn.nn.nnn
deny etc.
-------
In the .htaccess files in my _vti directories, the Options line looks like this:
Options None All -Indexes
So in this line, is it correct that None would be replaced with +FollowSymLinks?
If you put "Options All -Indexes" that should be equivalent.
The end result either way is that FollowSymLinks would be enabled, because it's included in "All".
Options [httpd.apache.org] documentation.
Jim
It does! I'd been wrestling with this unsuccessfully & had given up, so a sincere thank you to you, chopin 2256, & steveb.
The specific rewrite code I used to get http://example.co.nz to re-direct to www.example.co.nz is:
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.co.\nz [NC]
RewriteRule ^(.*)$ http://www.examplez.co.nz/$1 [L,R=301]
As steveb suggested I only needed to change the "Options None" to "Options +FollowSymLinks" just in each of the htaccess files of the 3 following FP directories only:
_vti_bin ; _vti_bin /_vti_adm ;& _vti_bin/ _vti_aut
The one outstanding issue I couldn't resolve & hopefully you can assist with is getting www.example.co.nz/index.htm to resolve to www.example.co.nz/.
To do this I tried adding RewriteRule ^index.html$ / [R=301,L] to the above Mod Rewriite code but it broke the re-direction because the server gets into an endless redirection loop.
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.co.\nz [NC]
RewriteRule ^(.*)$ http://www.examplez.co.nz/$1 [L,R=301]
^index.html$ / [R=301,L]
Anyone able to point out what I'm doing wrong here please?
Many thanks.
[edited by: engine at 11:21 am (utc) on Aug. 26, 2005]