vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Help with couple of mod_redirect rules (https://vborg.vbsupport.ru/showthread.php?t=320330)

Jaffery 09-23-2015 01:34 PM

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.

Dave 09-23-2015 03:23 PM

Hmm it should work fine..
What if you remove the slash before tags.php in your rewrite rule?

Jaffery 09-23-2015 06:37 PM

Quote:

Originally Posted by Dave (Post 2555608)
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.

kh99 09-23-2015 06:59 PM

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]

Dave 09-23-2015 07:04 PM

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?

Jaffery 09-23-2015 09:30 PM

Quote:

Originally Posted by kh99 (Post 2555618)
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 ?

Brandon Sheley 09-23-2015 09:49 PM

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.


All times are GMT. The time now is 08:11 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01082 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete