Apache2 rewrite without htaccess
Posted
by
inorganik
on Ask Ubuntu
See other posts from Ask Ubuntu
or by inorganik
Published on 2012-11-28T04:59:45Z
Indexed on
2012/11/28
5:26 UTC
Read the original article
Hit count: 368
apache
Reading up on doing url rewrites in Apache2, I found this:
"In general, you should never use .htaccess files unless you don't have access to the main server configuration file.
Okay, great. But there is no information anywhere about how to do it in the server configuration file. So before I mess stuff up, can I safely use the same rewrite directives, like
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^test/(\w+)$ test.php?n=$1 [L]
</IfModule>
in /etc/apache2/apache2.conf
? /etc/apache2/httpd.conf
is blank, but I suppose I could do it there too?
Another question, should the rewrite rule paths be prefixed with /var/www/
or can I do it relative to the site root? Thanks.
© Ask Ubuntu or respective owner