Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2005, 07:38 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Mod Rewrite - Image Paths

Basically I have /vb35rc1/blogs/username/ rewritten as /vb35rc1/blog.php?do=viewblog&un=username, but all my image paths point to /vb35rc1/blogs/username/images/. I looked up on google and found something like:
Code:
rewriteRule /vb35rc1/blogs/(.*)/images/ /vb35rc1/images/ [L]
Not much luck there though, under view source I see images/(image) now, but the images still won't show. Any pointers?

Thanks
Reply With Quote
  #2  
Old 08-03-2005, 09:29 PM
akanevsky akanevsky is offline
 
Join Date: Apr 2005
Posts: 3,972
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try the following:

Code:
rewriteBase /
rewriteRule ^vb35rc1/blogs/([A-z0-9\-\_]*)/images/([A-z0-9\-\_]*)$ vb35rc1/images/$2
Reply With Quote
  #3  
Old 08-03-2005, 09:31 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should start from scratch with these rules. Particularly because you are allowing the (.*) everything atom. mod_rewrite is a great first line of defence against hacking attempts so it's always best to specify what you want to put in the parentheses.

What exactly will go in the place of the (.*)'s ?
Reply With Quote
  #4  
Old 08-03-2005, 10:27 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks DV

Their username will go there of course, Dean.
Reply With Quote
  #5  
Old 08-03-2005, 10:43 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
RewriteBase /
RewriteRule ^vb35rc1/blogs/([A-Za-z0-9-_]+)/images/([A-Za-z0-9-_]+)/?$ vb35rc1/images/$2 [L]
That's a cleaned up version of Dark's code. There's no need to escape characters within the character classes in mod_rewrite. Also needed to add an optional trailing slash otherwise when users add a / on the end of your URL it'll break. I'm having trouble trying to see exactly what you are doing here though...
Reply With Quote
  #6  
Old 08-03-2005, 10:56 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cleaning URLs for blogging, but the image paths got all messed up after. All my rewrites work fine on my other site, just not the vB one because of how the images are setup.
Reply With Quote
  #7  
Old 08-04-2005, 09:37 AM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So do users have their own collection of images or something?
Reply With Quote
  #8  
Old 08-04-2005, 05:00 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No - so instead of having to type blog.php?do=view&u=1 they have to type /blogs/aj/ , just the result of doing so messed up the image paths (of course not just for me, for all users)
Reply With Quote
  #9  
Old 08-04-2005, 05:13 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In that case the above rule will not work. Use this:

Code:
RewriteEngine On
RewriteBase /
RewriteRule ^blogs/([A-Za-z0-9-_]+)/?$ blog.php?do=view&u=$1 [L]
That will assume that you pass the username to $_REQUEST[u]

RewriteBase will fix your problems with the image paths. put it in your vb3rc1 directory in a .htaccess file
Reply With Quote
  #10  
Old 08-04-2005, 05:50 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm..
Quote:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/1.3.33 Server at localhost Port 80
Code:
RewriteEngine On
RewriteBase /
RewriteRule ^blogs/([A-Za-z0-9-_]+)/?$ blog.php?do=view&un=$1 [L]
Reply With Quote
Reply

Thread Tools
Display Modes

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

Forum Jump


All times are GMT. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04152 seconds
  • Memory Usage 2,247KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete