Hi all, hope fully this is the right forum for my question. I want to have a structure like this on my site: www.mydomain.com/dir1/file1.html www.mydomain.com/dir2/file1.html etc. but dir1, dir2 etc. do NOT exist. I want to make use of mod_rewrite and do this: www.mydomain.com/dir1/file1.html ==> www.mydomain.com/index.php?id=file1 Can andybody help me or tell me how the code for this must look like? Thank you so much!
Options +FollowSymLinks RewriteEngine On RewriteRule ^dir1/([a-z0-9_-]*)\.html$ /index.php?id=$1 [L,NC] For more, you can use a small tool I wrote the other day: htaccess generator
Thanks but the problem is that the images are not shown anymore because of the wrong path!? Any solution for this?
Ok I tried: RewriteRule ^dir1/([a-z0-9_-]*)\.html$ http://www.mydomain.com/index.php?id=$1 [L,NC] Code (markup): which works fine, BUT it does a redirect then and the url in the browser looks like this: http://www.mydomain.com/index.php?id=blabla instead of: http://www.mydomain.com/folder1/blabla.html ??
You have toi edit the links to point to the new URLs. With images, the img code has to be as if the fake URLs are real URLs. Browsers don't know the URLs are fake.
Nintendo, that's not the problem here. The prob is that when I enter this in my browser: http://www.mydomain.com/folder1/blabla.html it redirects to http://www.mydomain.com/index.php?id=blabla It should not redirect but "http://www.mydomain.com/folder1/blabla.html" should appear in the browser url field. sorry for my bad english =) anybody have any idea??!
domain.com/.htaccess Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^dir1/([^.]+)\.html$ index.php?id=$1 [L] er, I would just keep the fake directory out!!!