apache - Can we use RewriteRule for internal paths? -
i've seen rewriterule used public url paths, can map urls internal paths?
for example, redirect links my_page.php, allowed? :
rewriterule .* /home/yccaucom/public_html/my_page.php [last,noescape]
you cannot redirect folder or file not within domain root.
given root folder is:
/home/yccaucom/public_html/
you can redirect within public_html
, example public_html/css
or public_html/some_folder
, can make symbolic link internal folder or file , should work well.
given rule, this:
rewritecond %{request_uri} !^/my_page.php$ [nc] rewriterule ^ /my_page.php [l,ne]
you want condition avoid falling infinite loop.
or check existent files/folders instead 2 conditions:
rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f
basically says if file or folder not exist redirect.
if try use rule is, try redirect to:
/home/yccaucom/public_html/home/yccaucom/public_html/my_page.php
however not fail since don't have verification stop loop give fail message saying many redirects or so.
on deeper @ rule, happens:
10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe85288af18/initial] (3) [perdir /home/account/public_html/] strip per-dir prefix: /home/account/public_html/asdasdas2 -> asdasdas2 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe85288af18/initial] (3) [perdir /home/account/public_html/] applying pattern '.*' uri 'asdasdas2' 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe85288af18/initial] (2) [perdir /home/account/public_html/] rewrite 'asdasdas2' -> '/home/account/public_html/edit.php' 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe85288af18/initial] (2) [perdir /home/account/public_html/] trying replace prefix /home/account/public_html/ / 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe85288af18/initial] (5) strip matching prefix: /home/account/public_html/edit.php -> edit.php 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe85288af18/initial] (4) add subst prefix: edit.php -> /edit.php 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe85288af18/initial] (1) [perdir /home/account/public_html/] internal redirect /edit.php [internal redirect] 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe852858798/initial/redir#1] (3) [perdir /home/account/public_html/] strip per-dir prefix: /home/account/public_html/edit.php -> edit.php 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe852858798/initial/redir#1] (3) [perdir /home/account/public_html/] applying pattern '.*' uri 'edit.php' 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe852858798/initial/redir#1] (2) [perdir /home/account/public_html/] rewrite 'edit.php' -> '/home/account/public_html/edit.php' 10.0.0.1 - - [24/aug/2013:05:25:24 --0300] [somedomain.com/sid#7fe8521040e0][rid#7fe852858798/initial/redir#1] (1) [perdir /home/account/public_html/] initial url equal rewritten url: /home/account/public_html/edit.php [ignoring rewrite]
Comments
Post a Comment