php - url rewrites removing folders .htaccess -


i want remove 'articles' , 'artificial' folders site's urls, when try introduce rewrite rules .htaccess file receiving errors.

http://www.example.com/articles/artificial/are_string_beans_all_right_on_the_candida_diet.php

trying convert

http://www.example.com/are_string_beans_all_right_on_the_candida_diet.php

here current version of .htaccess file

directoryindex index.php adddefaultcharset utf-8  rewritecond %{http_host} ^[^.]+\.[^.]+$ rewritecond %{https}s ^on(s)| rewriterule ^ http%1://www.%{http_host}%{request_uri} [l,r=301]  options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase /  rewriterule ^index\.php/?$ / [l,r=301,nc] rewriterule ^((?!articles/artificial).*)$ articles/artificial/$1 [nc,l] 

the problem should on last rule: need negative behind ie anything not preceede articles/artificial

the regex should be:

((?<!(articles/artificial)).*) 

but probabilly not work since .* variable length (see regex arrounds)

a solution replacing negative behind positive ahead allows variable length. rule be:

rewriterule ^(?!.*?articles/artificial.*?)(.*)$ /articles/artificial/$1 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -