Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/69346-solved-mod_rewritehtaccess-403-error/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.