tags:

views:

19

answers:

2

Hi everybody.

I have a doubt about url reqriting using apache mod_rewrite. I am a newbie in mod_rewrite and I dont have any experience in regex.

What I want to do is to:

Rewrite / To /web/content/public/

Rewrite /clients/ To /web/content/clients/

How can I acheive above things.

I tried:

   <IfModule mod_rewrite.c>

   Options +FollowSymLinks
   RewriteEngine on

   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l

   RewriteRule    ^/clients/$ web/content/clients/ [L]
   RewriteRule    ^(.*)$ web/content/public/$1 [L]
   </IfModule>

But it doesnt work. What can I do?

A: 

^(.*)$ includes the slash. So don't include the slash in the rewritten pattern. But include a root slash at the head of your rewritten pattern.

 RewriteRule    ^/clients(.*)$ /web/content/clients$1 [L]
 RewriteRule    ^(.*)$ /web/content/public$1 [L]

Check the apache access log and error log to see what kind of request URL comes back.

Please check the documentation, especially the list labeled "Here are all possible substitution combinations and their meanings:"

Joe Koberg
A: 

Try this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteRule ^/clients/$ web/content/clients/ [L]
RewriteRule ^/(.*)$ web/content/public/$1 [L]

And if you want to use that rules in a .htaccess file, remove the leading slash from the patterns.

Gumbo