Go Back   vb.org Archive > Community Discussions > Forum and Server Management
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2014, 06:56 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default htaccess rewrite issue

I am trying to do some rewrites and finally trying to master htaccess but nothing seems to be working for me.

To start I need to send everything under the top listed forum to the bottom one.

PHP Code:
http://musclemecca.com/mecca-bodybuilding-discussion-news-226/

To

http
://musclemecca.com/forums/226-MuscleMecca-HeadQuarters 
I have tried the following to no avail-

PHP Code:
RewriteCond %{HTTP_USER_AGENTbodybuilding\-discussion\-226/ [OR]  RewriteCond %{HTTP_USER_AGENThttp\://musclemecca\.com/mecca\-bodybuilding  \-discussion\-news\-226/  RewriteRule *. http://musclemecca.com/forums/226-MuscleMecca-HeadQuarters - [R,L]I also tried

RewriteRule ^bodybuilding-discussion-226/.* forumdisplay.php [QSA
Could someone point me in the right direction here? I am about to pull my hair out.

Thanks,
Rich
Reply With Quote
  #2  
Old 01-15-2014, 07:27 AM
ikopylov's Avatar
ikopylov ikopylov is offline
 
Join Date: Aug 2010
Location: Russia
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
Options +FollowSymLinks
RewriteEngine On

RedirectMatch 301 ^/([A-Za-z0-9-]+)-([0-9]+)/$  http://musclemecca.com/forums/$2-$1
Reply With Quote
Благодарность от:
RichieBoy67
  #3  
Old 01-15-2014, 09:20 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much. It appears as if I was not even close. The first one was a mixture of a tool I had used and my own edits and the second one I wrote myself.

After looking at your code I am very lost.

--------------- Added 15 Jan 2014 at 05:28 ---------------

# - Update

Doesn't seem to work - I believe due to the current rewrite rules already on my htaccess, some of which are not working either.

PHP Code:
RewriteEngine on

RewriteRule f
[\d]+/.+-([\d]+)/index([\d]+).html showthread.php?t=$1&page=$[L,R=301]
RewriteRule f[\d]+/.+-([\d]+)/ showthread.php?t=$[L,R=301]
RewriteRule f([\d]+)/index([\d]+).html forumdisplay.php?f=$1&page=$[L,R=301]
RewriteRule f([\d]+)/ forumdisplay.php?f=$[L,R=301]

# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.musclemecca\.com$ [NC]
RewriteRule ^(.*)$ http://musclemecca.com/$1 [L,R=301]

RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$[L]

# If you are having problems with the rewrite from content/ to content.php, uncomment this line to turn MultiViews off.
Options -MultiViews

RewriteCond 
%{REQUEST_FILENAME} -[OR]
RewriteCond %{REQUEST_FILENAME} -[OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule 
^.*$ - [NC,L]

# Forum
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]
RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]

RewriteCond %{REQUEST_FILENAME} -[OR]
RewriteCond %{REQUEST_FILENAME} -[OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule 
^.*$ - [NC,L]

# MVC
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$[QSA]

# Check MVC result
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule 
^(.*)$ - [NC,L]
RewriteRule ^(.*)$ - [R=404,L]

## Expires
<ifModule mod_expires.c>
        
ExpiresActive On
        ExpiresDefault 
"access plus 1 seconds"
        
ExpiresByType text/html "access plus 1 seconds"
        
ExpiresByType image/gif "access plus 3456000 seconds"
        
ExpiresByType image/jpeg "access plus 3456000 seconds"
        
ExpiresByType image/png "access plus 3456000 seconds"
        
ExpiresByType text/css "access plus 3456000 seconds"
        
ExpiresByType text/javascript "access plus 3456000 seconds"
        
ExpiresByType application/javascript "access plus 3456000 seconds"
        
ExpiresByType application/x-javascript "access plus 3456000 seconds"
</ifModule>

## Compression
<ifmodule mod_headers.c>
        <
ifmodule mod_deflate.c>
                
AddOutputFilterByType DEFLATE text/html text/css text/xml application/x-javascript
                BrowserMatch 
^Mozilla/4 gzip-only-text/html
                BrowserMatch 
^Mozilla/4\.0[678no-gzip
                BrowserMatch 
\bMSIE !no-gzip !gzip-only-text/html
        
</ifmodule>
</
ifmodule>

## Rewrites
<ifmodule mod_rewrite.c>
        
RewriteEngine on
        Options 
+FollowSymlinks

        RewriteCond 
%{REQUEST_FILENAME} -[OR]
        
RewriteCond %{REQUEST_FILENAME} -[OR]
        
RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule 
^.*$ - [NC,L]

        
# Media Library
        
ReWriteRule ^media/m(\d+).*/tagsmedia.php?do=tags_edit&mid=$[QSA]
        
ReWriteRule ^media/m(\d+).*/editmedia.php?do=details_edit&mid=$[QSA]
        
ReWriteRule ^media/m(\d+).*/reportmedia.php?do=report&mid=$[QSA]
        
ReWriteRule ^media/m(\d+).*/c(\d+)$ media.php?do=comment_edit&cmt=$[QSA]
        
ReWriteRule ^media/m(\d+).*/p(\d+).*$ media.php?do=details&mid=$1&pid=$[QSA]
        
ReWriteRule ^media/m(\d+).* media.php?do=details&mid=$[QSA]
        
ReWriteRule ^media/p(\d+).*/editmedia.php?do=playlist_edit&pid=$[QSA]
        
ReWriteRule ^media/p(\d+).* media.php?do=playlist&pid=$[QSA]
        
ReWriteRule ^media/c(\d+).* media.php?do=category&cid=$[QSA]
        
ReWriteRule ^media/u(\d+).* media.php?do=user&uid=$[QSA]
        
ReWriteRule ^media/tag/(.*) media.php?do=tag&tid=$[QSA]
        
ReWriteRule ^media/results/(.*) media.php?do=results&query=$[QSA]
        
ReWriteRule ^media/advresults/(.*) media.php?do=advresults&query=$[QSA]
        
ReWriteRule ^media/letter/(.*) media.php?do=letter&query=$[QSA]
        
ReWriteRule ^media/browse.* media.php?do=browse [QSA]
        
ReWriteRule ^media/search.* media.php?do=search [QSA]
        
ReWriteRule ^media/random.* media.php?do=random [QSA]
        
ReWriteRule ^media/submit.* media.php?do=submit [QSA]
        
ReWriteRule ^media/tagcloud.* media.php?do=tagcloud [QSA]
        
ReWriteRule ^media/playlists.* media.php?do=playlists [QSA]
        
ReWriteRule ^media/pcreate.* media.php?do=playlists_create [QSA]
        
ReWriteRule ^media/pmine.* media.php?do=playlists_mine [QSA]
        
ReWriteRule ^media/favorites.* media.php?do=favorites [QSA]
        
ReWriteRule ^media/subscriptions.* media.php?do=subscriptions [QSA]
        
ReWriteRule ^media/admin/edit/s(\d+).* media.php?do=admin_host_edit&sid=$[QSA]
        
ReWriteRule ^media/admin/delete/s(\d+).* media.php?do=admin_host_delete&sid=$[QSA]
        
ReWriteRule ^media/admin/export/s(\d+).* media.php?do=admin_host_export&sid=$[QSA]
        
ReWriteRule ^media/admin/(\w+).* media.php?do=admin_$[QSA]

        
# Media Library from Video Directory
        
RewriteCond %{QUERY_STRING} do=viewdetails&videoid=(\d+)
        
RewriteRule ^video\.phpmedia.php?do=details&mid=%1
        RewriteCond 
%{QUERY_STRINGviewcategory&categoryid=(\d+)
        
RewriteRule ^video\.phpmedia.php?do=category&cid=%1
        RewriteCond 
%{QUERY_STRINGviewuser&userid=(\d+)
        
RewriteRule ^video\.phpmedia.php?do=user&uid=%1
        RewriteCond 
%{QUERY_STRINGviewtag&tag=(.*)
        
RewriteRule ^video\.phpmedia.php?do=tag&tid=%1
        ReWriteRule 
^video\.phpmedia.php

        
# Forum
        
RewriteRule ^threads/.* showthread.php [QSA]
        
RewriteRule ^forums/.* forumdisplay.php [QSA]
        
RewriteRule ^members/.* member.php [QSA]
        
RewriteRule ^blogs/.* blog.php [QSA]
        
ReWriteRule ^entries/.* entry.php [QSA]

        
RewriteCond %{REQUEST_FILENAME} -[OR]
        
RewriteCond %{REQUEST_FILENAME} -[OR]
        
RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule 
^.*$ - [NC,L]

        
# MVC
        
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$[QSA]
</
ifmodule>

<
IfModule mod_headers.c>
    <
FilesMatch "\.(bmp|css|flv|gif|ico|jpg|jpeg|js|pdf|png|svg|swf|tif|tiff)$">
        
Header set Last-Modified "Mon, 15 Feb 2013 00:00:00 GMT"
    
</FilesMatch>
</
IfModule
Thanks again for the reply,
Rich
Reply With Quote
  #4  
Old 01-15-2014, 10:07 AM
ikopylov's Avatar
ikopylov ikopylov is offline
 
Join Date: Aug 2010
Location: Russia
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wait little time, i write for you some rulers for writing htaccess
I am russian and it's hard to formulate
Reply With Quote
  #5  
Old 01-15-2014, 10:17 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That would be amazing! Thank you very much for your help and no need to rush.

I understand some of the rules but putting them together is tough for me. I have been working on learning this so your help is greatly appreciated.
Reply With Quote
  #6  
Old 01-16-2014, 07:35 AM
ikopylov's Avatar
ikopylov ikopylov is offline
 
Join Date: Aug 2010
Location: Russia
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1
Root htaccess should be as short as possible and so that there were fewer rules as
Any rules slow down the speed of opening a website.

2
Try to use Redirect and RedirectMatch.
In particular, RewriteRULE load slow down the site

3
Very great importance sequence of rules.

Example
read 1 line, there is a match - execute, no: read a line 2
read 2 line, there is a match - execute, no: read a line 3
etc

RewriteRULE performed primarily from any row

4
Divide your htaccess into several parts

For example:
If you have two or more lines that comply with the rules of redirects in site.com/TAGS/
Create a folder on the server TAGS
And put new htaccess with redirects in this folder

5
Images.
Create a subdomain IMAGE and drag it all the images.
it's make "parallel loading" of images, and accelerate the discovery of page
At the root of the subdomain images.site.com create htaccess with all settings for images

Sorry for my bad english )))
Reply With Quote
Благодарность от:
RichieBoy67
  #7  
Old 01-16-2014, 08:14 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Ikopylov! That was really helpful. I did not even think of #4 to solve some of the issues I am having! Nice and simple.

Really appreciated it,
Rich

BTW - Your english is better than many people I know who speak English as a primary language.
Reply With Quote
2 благодарности(ей) от:
CAG CheechDogg, ikopylov
  #8  
Old 01-16-2014, 10:08 AM
ikopylov's Avatar
ikopylov ikopylov is offline
 
Join Date: Aug 2010
Location: Russia
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by RichieBoy67 View Post
I did not even think of #4
At you htaccess (post #3) you write 28 lines of ReWriteRule, which operate in media folder ( www.site.com/media/ )
Del this lines in root htaccess.
Create new file: www.site.com/media/.htaccess with this 28 lines
Reply With Quote
  #9  
Old 01-16-2014, 11:04 AM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks

Yes, that makes sense with the media folder. I will do that definitely.

The problem I am having though mainly is with the urls that do not have folders and no longer exist such as

Code:
/bodybuilding-discussion-news-226/official-mecca-top-6-guess-rules-standings-thread-2013-a-

220802/index2.html


to

http://musclemecca.com/threads/220802-***Official-Mecca-Top-6-Guess-rules-amp-standings-

thread***-2013?highlight=rules+standings
A simple redirect will not work for this. If the url was shorter I would be able to do it but the long ones really mess me up.

What is confusing me is that this url is a thread under a forum but it is not using the forum directory. Trying to write rule to redirect all past urls under a certain forum to the new forum they were moved too.

Thanks again. I am learning slowly.
Reply With Quote
Благодарность от:
CAG CheechDogg
  #10  
Old 01-16-2014, 09:50 PM
ikopylov's Avatar
ikopylov ikopylov is offline
 
Join Date: Aug 2010
Location: Russia
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by RichieBoy67 View Post
The problem I am having though mainly is with the urls that do not have folders and no longer exist such as

Code:
/bodybuilding-discussion-news-226/official-mecca-top-6-guess-rules-standings-thread-2013-a-220802/index2.html

to

http://musclemecca.com/threads/220802-***Official-Mecca-Top-6-Guess-rules-amp-standings-thread***-2013?highlight=rules+standings
A simple redirect will not work for this. If the url was shorter I would be able to do it but the long ones really mess me up.
For this part you can not
appeal
attention
?highlight=rules+standings
----------------------
vBseo remove this symbols^ "***"
these characters are not in the old *** link
Therefore, if the redirect server can not find their match
That's the only way how you can make a redirect :
Code:
Options +FollowSymLinks
RewriteEngine On

Redirect 301 /bodybuilding-discussion-news-226/official-mecca-top-6-guess-rules-standings-thread-2013-a-220802/index2.html http://musclemecca.com/threads/220802-***official-mecca-top-6-guess-rules-amp-standings-thread***-2013/page2
Redirect 301 /bodybuilding-discussion-news-226/official-mecca-top-6-guess-rules-standings-thread-2013-a-220802/index3.html http://musclemecca.com/threads/220802-***official-mecca-top-6-guess-rules-amp-standings-thread***-2013/page3
Redirect 301 /bodybuilding-discussion-news-226/official-mecca-top-6-guess-rules-standings-thread-2013-a-220802 http://musclemecca.com/threads/220802-***official-mecca-top-6-guess-rules-amp-standings-thread***-2013
These characters "***" and not enough
therefore, this is the only option as you can make a redirect

---------------------------

There is another option, but it's a bad idea to implement.

Code:
RedirectMatch 301 ^/([a-z-]+)-([0-9]+)/([a-z0-9-]+)-([0-9]+)$ http://musclemecca.com/threads/$4
That code must be placed in the bottom, a set of rules that apply to the triad

Execution sequence for example:
RedirectMatch old thread+post => new thread+post
RedirectMatch old thread+pool => new thread+pool
RedirectMatch old thread => new thread
RedirectMatch my bad kod => you bad thread

Short link will be used:
http://musclemecca.com/threads/220802
This is good for the user, it gets to the desired page, but bad for search engine: it will be a duplicate page.

---------------------------
It's important:
Do not forget that Unix understands this:
Letter
letter

As two different words. In windows it as one word
Reply With Quote
Благодарность от:
RichieBoy67
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 11:41 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.04474 seconds
  • Memory Usage 2,393KB
  • Queries Executed 13 (?)
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
  • (3)bbcode_php
  • (2)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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (6)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit
  • (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_postinfo_query
  • fetch_postinfo
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete