Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2015, 01:34 PM
Jaffery Jaffery is offline
 
Join Date: Dec 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Help with couple of mod_redirect rules

Since, I just got rid of vbseo, now I am trying to deal with redirect as much as possible. Taking care of threads was easy however still urls like tags, attachments etc. remains.. so, I hope guys here may help me through with their wisdom in mod_rewrite rules .. regex

So, I am stuck on this.. wants to do following:

redirect:
domain.com/talk/tags/letter.html (letter is tag)

To

domain.com/talk/tags.php?tag=letter


I tried this

Code:
RewriteRule tags/([^/]+)\.html /tags.php?tag=$1 [L,R=301]
But its not working.

My forum is at :
domain.com/talk

And I am adding above rule in domain.com/talk/.htaccess with "RewriteBase /talk/" .
This is where I have added thread redirection code which works fine.
Reply With Quote
  #2  
Old 09-23-2015, 03:23 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm it should work fine..
What if you remove the slash before tags.php in your rewrite rule?
Reply With Quote
  #3  
Old 09-23-2015, 06:37 PM
Jaffery Jaffery is offline
 
Join Date: Dec 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
Hmm it should work fine..
What if you remove the slash before tags.php in your rewrite rule?
Nope its not working, and if I remove / from tags.php , it will add absolute path to the file.. but here first thing is that it should detect the rule at first place.
Reply With Quote
  #4  
Old 09-23-2015, 06:59 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Maybe you want [^.], like
Code:
RewriteRule /tags/([^.]+)\.html /tags.php?tag=$1 [L,R=301]

ETA: Hmm...or in case tags can show up elsewhere in the path, maybe both . and /, like
Code:
RewriteRule /tags/([^./]+)\.html /tags.php?tag=$1 [L,R=301]
Reply With Quote
  #5  
Old 09-23-2015, 07:04 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could it be that an other rewrite rule is being applied before it reaches that one? Can you post all the contents of your .htaccess file?
Reply With Quote
  #6  
Old 09-23-2015, 09:30 PM
Jaffery Jaffery is offline
 
Join Date: Dec 2009
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Maybe you want [^.], like
Code:
RewriteRule /tags/([^.]+)\.html /tags.php?tag=$1 [L,R=301]

ETA: Hmm...or in case tags can show up elsewhere in the path, maybe both . and /, like
Code:
RewriteRule /tags/([^./]+)\.html /tags.php?tag=$1 [L,R=301]

Thanks guys, it worked with following: (and yes there were some conflicting rules from default vb)


Code:
RewriteRule tags/([^.]+)\.html /talk/tags.php?tag=$1 [L,R=301]
Now I need to handle attachment urls :

Its like :
Code:
http://domain.com/members/username/albums/my-updates/2451-user-privacy-security.jpg
Here 2451 is image ID:

I did this :

Code:
RewriteRule members.+/([\d]+)-.+\.jpg http://domain.com/talk/attachment.php?attachmentid=$1 [L,R=301]
Again not working..

No matter how much I read about regex, its always confusing for me, can you guys confirm if I read it correct :

[^/] mean any character except /
so,
[^./] means any character exept . and /

am I reading it right ?

--------------- Added [DATE]1443051370[/DATE] at [TIME]1443051370[/TIME] ---------------

Well.. I donno but now its working .. for precaution I have added condition for attachment url redirect:

Code:
#image attachment
RewriteCond %{REQUEST_URI} /albums/ [NC]
RewriteRule members.+/([\d]+)-.+\.jpg http://domain.com/talk/attachment.php?attachmentid=$1 [L,R=301]
Is it as I think, ie. first checking condition if URI contains /albums/ word and then only proceed for further match and redirect ?
Reply With Quote
  #7  
Old 09-23-2015, 09:49 PM
Brandon Sheley's Avatar
Brandon Sheley Brandon Sheley is offline
 
Join Date: Mar 2005
Location: Google Kansas
Posts: 4,678
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know Joe @BirdOfPrey... oh ya,, vb doesn't do that

Well anyways, he helped me out tremendously with some redirects.
Maybe He'll see this thread and post.
Reply With Quote
Reply


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 08:55 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.03837 seconds
  • Memory Usage 2,222KB
  • 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
  • (9)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete