regex - What is wrong with me redirect regular expression? -
i have 2 redirects , both redirect internally.
rewriteengine on rewritecond %{http_host} ^[^.]+\.[^.]$ rewriterule ^(.+) %{http_host}$1 [c] rewriterule ^(.*)\/(.*) /var/www/$1/www.$1/$2 #this line not working rewriterule ^(.+) %{http_host}$1 [c] rewriterule ^([^.]+)\.(.*/)(.*) /var/www/$2$1.$2$3 i cant first 1 working. should doing: url: example.org/the/uri/the/user/used rewriterule should redirect him to: /var/www/example.org/www.example.org/the/uri/the/user/used
so question is: regular look i'm looking for?
edit:
this engine :)
<virtualhost *:80> serveradmin *@gmail.com documentroot /var/www/html errorlog ${apache_log_dir}/error.log customlog ${apache_log_dir}/access.log combined rewriteengine on rewritecond %{http_host} ^[^.]+\..[^.]+$ rewriterule ^(.+) %{http_host}$1 [c] rewriterule ^([^\/]*)(.*)$ /var/www/$1/www.$1/$2 [l] rewriterule ^(.+) %{http_host}$1 [c] rewriterule ^([^.]+)\.(.*/)(.*) /var/www/$2$1.$2$3 [l] </virtualhost> it redirect example.org internally /var/www/example.org/www.example.org , sec part. redirects foo.example.org /var/www/example.org/foo.example.org
your regex be,
^[^:]*:\s*([^\/]*)(.*)$ without uri section, regex be,
^([^\/]*)(.*)$ demo
explanation:
url: example.org/the/uri/the/user/used in above example, string after : , next / captured group1. , remaining part captured group2. giving /var/www/$1/www.$1$2 in substitution part may give desired result.(marker denoting captured grouping may vary upon languages, used $ representing captured group).
regex apache mod-rewrite redirect
No comments:
Post a Comment