Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem with URL Rewriting (.htaccess)
Old 03-07-2008, 12:12 PM Problem with URL Rewriting (.htaccess)
Experienced Talker

Posts: 44
Name: Jonathan Roy
Location: Montreal, Quebec, Canada
Trades: 0
Hi,

I am using URL rewriting for my website so my urls look like that:

Code:
mywebsite.com/section/categorie/id.html
My .htaccess file is :

Code:
RewriteEngine on
RewriteRule ^(.*)/(.*)/(.*).html index.php?section=$1&categorie=$2&id=$3 [L]
RewriteRule ^(.*)/(.*)/ index.php?section=$1&categorie=$2 [L]
RewriteRule ^(.*)/ index.php?section=$1 [L]
It works OK but I can't access my images in the directory /images/ because it rewrites it and think I want $section = "images"

Can someone help?

Thanks
jonroy is offline
Reply With Quote
View Public Profile Visit jonroy's homepage!
 
 
Register now for full access!
Old 03-07-2008, 07:27 PM Re: Problem with URL Rewriting (.htaccess)
Extreme Talker

Posts: 246
Trades: 3
I'm a little rusty, but would something like this work? (Granted you never have a $section == "images" scenario)

Code:
RewriteEngine on
RewriteRule ^(.*)/(.*!(images))/(.*).html index.php?section=$1&categorie=$2&id=$3 [L]
RewriteRule ^(.*)/(.*!(images))/ index.php?section=$1&categorie=$2 [L]
RewriteRule ^(.*)/ index.php?section=$1 [L]
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
CouponGuy is offline
Reply With Quote
View Public Profile
 
Old 03-07-2008, 07:39 PM Re: Problem with URL Rewriting (.htaccess)
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Not a bad try CouponGuy, but there is a little more flexable method reguardless of the directory name. This is untested on my end, but it should be good, or may need a little tweaking.

Code:
RewriteEngine on
 
# if url is pointing to a valid file, allow it:
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1?%{QUERY_STRING} [L]
 
# if url is pointing to a valid dir, allow it:
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ $1?%{QUERY_STRING} [L]
 
# continue rewrites:
RewriteRule ^(.*)/(.*)/(.*)\.html$ index.php?section=$1&categorie=$2&id=$3&%{QUERY_STRING} [L]
RewriteRule ^(.*)/(.*)/ index.php?section=$1&categorie=$2&%{QUERY_STRING} [L]
RewriteRule ^(.*)/ index.php?section=$1&%{QUERY_STRING} [L]
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic; 03-07-2008 at 08:05 PM.. Reason: edited goof
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 03-07-2008, 07:47 PM Re: Problem with URL Rewriting (.htaccess)
Extreme Talker

Posts: 246
Trades: 3
Hey, that's a great idea! Way to be dynamic!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
CouponGuy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with URL Rewriting (.htaccess)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.50125 seconds with 12 queries