directory structure question

Discuss practical ways rearrange URLs using mod_rewrite.

directory structure question

Postby burhankhan » Mon Apr 04, 2005 2:13 am

Hi:
i am new in mod_rewrite :)

i want to rewrite URL:
http://www.mydomain.com/dir/a/cat-display-pics.html

to:
http://www.mydomain.com/dir/display-pic ... =$1&cat=$2

i try some rewriting codes for this, but :(

Also i am using .htacess file in each directory. So this .htaccess file will b place in "DIR" directory. e.g "http://www.mydomain.com/dir/"

Can any body help?
Thanks
burhankhan
 
Posts: 3
Joined: Mon Apr 04, 2005 1:57 am

Postby Caterham » Mon Apr 04, 2005 3:41 pm

Did you try
Code: Select all
RewriteEngine on
RewriteRule ^([a-z0-9]+)/([a-z0-9_]+)-display-pics\.html$ /dir/display-pic.php?id=$1&cat=$2 [NC,L]
?
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby burhankhan » Tue Apr 05, 2005 1:55 am

See what i want:
http://mysite.com/msn/a/funny-display-pics.html

to: http://mysite.com/msn/display-pics.php?cat=funny&id=a

I try that code, and place my .htaccess file in msn directory (not at root directory):

Code: Select all
RewriteEngine on
RewriteRule ^([a-z0-9]+)/([a-z0-9_]+)-display-pics\.html$ display-pic.php?id=$1&cat=$2 [NC,L]


But it is not working (404 error).
I change it a little, and place in my www folder (root directory).

Code: Select all
RewriteEngine on
RewriteRule ^msn/(.*)/([a-z0-9_]+)-display-pics\.html$ /msn/display-pic.php?id=$1&cat=$2 [NC,L]


i change ([a-z0-9]+) to (.*), now it is working, but images and links in that page, are not valid. Such as orignal image path is: http://mysite.com/msn/images/image.jpg but when i check image path in that page, it is: http://mysite.com/msn/a/images/image.jpg

So what to do? Also what is purpose of [NC,L]? I remove it, and there is no effect.

2) i write this code for changing every php file to html file:

Code: Select all
RewriteRule ^msn/(.*)\.html$ msn/$1.php


It is working properly. Is it efficient way to change every php file to html?
burhankhan
 
Posts: 3
Joined: Mon Apr 04, 2005 1:57 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 60 guests

cron