socoljam Posted September 14, 2007 Share Posted September 14, 2007 I'm having a problem with an .htaccess file and apparently mod_rewrite, hopefully someone here can offer some insight! Basically, I'm trying to rewrite a short, pretty URL to a long, ugly URL. Here's the entire .htaccess file # pretty url rewriting for online tutoring #RewriteEngine on #RewriteRule ^/onlinetutoring(/(.*))? /socol/onlinetutoring/index.php=$2 [L,QSA] This is the .htaccess for my DocumentRoot (/home/web/public_html) directory. The problem is this: as soon as I uncomment either line, I get 403 errors for every page on the server. Even if I only uncomment "RewriteEngine on" and not the rule, I get 403 errors everywhere. Here's the relevant line of the ls -lhA $ ls -lhA | grep htaccess -rwxr-xr-x 1 root:web 162 Sep 14 11:25 .htaccess Has anyone else encountered/solved this? If so, how? Thanks in advance! ~james Quote Link to comment Share on other sites More sharing options...
socoljam Posted September 14, 2007 Author Share Posted September 14, 2007 Solved! I would like very much if someone would explain why mod_rewrite requires Options +FollowSymLinks to be turned on. Quote Link to comment Share on other sites More sharing options...
effigy Posted September 14, 2007 Share Posted September 14, 2007 From the docs: Per-directory Rewrites The rewrite engine may be used in .htaccess files. To enable the rewrite engine for these files you need to set "RewriteEngine On" and "Options FollowSymLinks" must be enabled. If your administrator has disabled override of FollowSymLinks for a user's directory, then you cannot use the rewrite engine. This restriction is required for security reasons. When using the rewrite engine in .htaccess files the per-directory prefix (which always is the same for a specific directory) is automatically removed for the pattern matching and automatically added after the substitution has been done. This feature is essential for many sorts of rewriting; without this, you would always have to match the parent directory, which is not always possible. There is one exception: If a substitution string starts with http://, then the directory prefix will not be added, and an external redirect (or proxy throughput, if using flag P) is forced. See the RewriteBase directive for more information. The rewrite engine may also be used in <Directory> sections with the same prefix-matching rules as would be applied to .htaccess files. It is usually simpler, however, to avoid the prefix substitution complication by putting the rewrite rules in the main server or virtual host context, rather than in a <Directory> section. Although rewrite rules are syntactically permitted in <Location> sections, this should never be necessary and is unsupported. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.