Friday, 15 May 2015

mod rewrite - mod_rewrite and .htaccess: Can my RewriteRule substitution be a subfolder in DocumentRoot's parent folder? -



mod rewrite - mod_rewrite and .htaccess: Can my RewriteRule substitution be a subfolder in DocumentRoot's parent folder? -

thanks help in advance.

here's , trying accomplish:

i have static files in /home/username/code/project/static/ my document root /home/username/public_html/ (which .htaccess file is).

i'm trying utilize next in .htaccess file (i have no access httpd.conf):

rewriterule ^(static/.*)$ /home/username/code/project/static/ [l]

but if understand mod_rewrite's documentation correctly (see below), "/home/username/code/project/static/" treated either file-system path relative document root or url path, not absolute file-system path intended.

i tried using "~/code/project/static/" , "../code/project/static/", got internal server error when trying visit page (yes, i'm bit of noob).

so question is: there way substitution of rewrite rule used in .htaccess context absolute file-system path rather path relative documentroot?

here's extract mod_rewrite documentation reference (can found in total here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule):

for example, if specify substitution string of /www/file.html, treated url-path unless directory named www exists @ root or file-system (or, in case of using rewrites in .htaccess file, relative document root), in case treated file-system path.

any help much appreciated :)

thanks!

one way accomplish you're trying create symlink within public_html points static /home/username/code/project/static/. requires followsymlnks alternative detailed in options directive documentation may not allowed within total apache configuration, out of control.

a improve approach reverse link - create public_html/static maintain real files , create /home/username/code/project/static symlink public_html/static. avoids need specific .htaccess rules. since seems want create files under directory publicly-accessible anyways, it's improve security-wise since keeps publicly-accessible files under same directory construction , avoids potential security issues arise allowing symlinks go within web root other areas of file system.

.htaccess mod-rewrite

No comments:

Post a Comment