Reputation: 1065
For instance, if a user requests /nonexistentdirectory
, how could the hit be redirected to /hits.php?d=nonexistentdirectory
?
I've tried the following code in my apache.conf; however, it is replying with an error code:
<Directory /var/www/>
RewriteEngine On
# No redirect, if file or directory exists
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^([A-Za-z0-9-]+)/?$ link/index.php?a=$1 [L]
</Directory>
Error code:
Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden
All suggestions are appreciated!
Upvotes: 2
Views: 127
Reputation: 19016
You must enable FollowSymLinks
option as it is said.
<Directory /var/www/>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^/?([^/]+)/?$ link/index.php?a=$1 [L]
</Directory>
Upvotes: 2