Hi All!

I am really confuse as to how I use the mod_rewrite.. What are the steps to use this?
Here are what I did:
1. Check if mod_rewrite loaded/enabled in Apache modules. ->Yes

  1. I have written this in my httpd.conf:

           <Directory "/var/opt/htdocs/sample">
               AllowOverride FileInfo Options
          </Directory>    
  2. Then I put the .htaccess file under the /sample directory.

  3. Here is my htaccess file.
    RewriteEngine On
    RewriteRule img/([a-Z-A-z])/?$ sample/image.php?imgname=$1

But when I access my url for this it gives me: "The webpage cannot be found error"
i.e. http://abc.co.jp/sample/img/myimage.jpg

What am I doing wrong? Please help! 😕

    Your pattern is wrong:

    RewriteEngine On
    RewriteRule ^img/([a-zA-Z]*)/?$ sample/image.php?imgname=$1

      Or you could simply do:

      RewriteRule ^img/([a-z]*)/?$ sample/image.php?imgname=$1 [NC]

        my way is shorter, by 2 characters :p

          Yes, but you bumped caps lock and tried to link to 'IMG/sDFDFDF.jpg' it wouldn't work! :p

            It's okay brad... same thing happened to me last night 😉

              hi! thanks for the replies...

              i've tried your suggestions but i still can't get it to work!... it is still showing the picture.... i am just printing some text on the image.php for now...

              i looked at the rewrite_log file:
              (2) init rewrite engine with requested uri /sample/img/f.jpg
              (1) pass through /sample/img/f.jpg

              is mod_rewrite really working?

              by the way, i am using Linux server with apache and tomcat, java, php.... does it have any conflict?

              😕

                Try this rule:

                RewriteRule ^img/([a-zA-Z]*)[/]? sample/image.php?imgname=$1

                Oh, and no conflicts with that server setup 😉

                  Write a Reply...