1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help me with my htaccess file!

Discussion in 'Installation, Upgrade, and Import Support' started by petertdavis, Jul 11, 2013.

  1. petertdavis

    petertdavis Well-Known Member

    I just converted CoinTalk.com to Xenforo (after ten years of vBulletin!). And,I'm trying to get the redirects right so the old urls work. I had vbSEO installed. Obviously, I'm not too talented with this stuff. This is what I have in htaccess for coin talk, but it doesn't really work:

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    #    cannot attach files, remove the "#" from the lines below.
    #<IfModule mod_security.c>
    #    SecFilterEngine Off
    #    SecFilterScanPOST Off
    #</IfModule>
    
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
    <IfModule mod_rewrite.c>
        RewriteEngine On
        #    If you are having problems with the rewrite rules, remove the "#" from the
        #    line that begins "RewriteBase" below. You will also have to change the path
        #    of the rewrite to reflect the path to your XenForo installation.
        #RewriteBase /xenforo
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
    RewriteEngine on
    RewriteRule t([\d]+)-([\d]+)/ showthread.php?t=$1&page=$2 [NC,L]
    RewriteRule t([\d]+)/ showthread.php?t=$1 [NC,L]
    RewriteRule f([\d]+)-([\d]+)/ forumdisplay.php?f=$1&page=$2 [NC,L]
    RewriteRule f([\d]+)/ forumdisplay.php?f=$1 [NC,L]
    for example, this url
    http://www.cointalk.com/t198026/
    should redirect to this one
    http://www.cointalk.com/threads/rim-is-sillver-on-canadian-penny.198026/
    but it doesn't.

    And this one
    http://www.cointalk.com/f30/
    should redirect to this one
    http://www.cointalk.com/forums/coin-chat.30/

    obviously I'm doing something wrong and I'd greatly appreciate if anyone could help me get this right. :)
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Does it redirect to showthread.php?t=$1&page=$2?

    Try:
    Code:
    RewriteRule t([\d]+)-([\d]+)/ /threads/$1?page=$2 [L,R=301]
    RewriteRule t([\d]+)/ /threads/$1 [L,R=301]
    RewriteRule f([\d]+)-([\d]+)/ /forums/$1?page=$2 [L,R=301]
    RewriteRule f([\d]+)/ /forums/$1 [L,R=301]
    (replacing last 4 lines)
    Note: I haven't tested these and I'm not the best at .htaccess redirects.
     
  3. petertdavis

    petertdavis Well-Known Member

    You mean like this?

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    #    cannot attach files, remove the "#" from the lines below.
    #<IfModule mod_security.c>
    #    SecFilterEngine Off
    #    SecFilterScanPOST Off
    #</IfModule>
    
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
    <IfModule mod_rewrite.c>
        RewriteEngine On
        #    If you are having problems with the rewrite rules, remove the "#" from the
        #    line that begins "RewriteBase" below. You will also have to change the path
        #    of the rewrite to reflect the path to your XenForo installation.
        #RewriteBase /xenforo
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
    RewriteEngine on
    RewriteRule t([\d]+)-([\d]+)/ /threads/$1?page=$2 [L,R=301]
    RewriteRule t([\d]+)/ /threads/$1 [L,R=301]
    RewriteRule f([\d]+)-([\d]+)/ /forums/$1?page=$2 [L,R=301]
    RewriteRule f([\d]+)/ /forums/$1 [L,R=301]
    Didn't seem to change anything, but thanks for trying.
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    What is exactly happening when you hit those URLs?
     
  5. petertdavis

    petertdavis Well-Known Member

  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    Hm, I wonder why it isn't redirecting. @Jake Bunce is usually a htaccess ninja.
     
  7. petertdavis

    petertdavis Well-Known Member

    Thanks, Jake just replied to me privately with the solution.
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Wrong order of rules. Use this:

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    #    cannot attach files, remove the "#" from the lines below.
    #<IfModule mod_security.c>
    #    SecFilterEngine Off
    #    SecFilterScanPOST Off
    #</IfModule>
    
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
    <IfModule mod_rewrite.c>
        RewriteEngine On
    
    RewriteRule t([\d]+)-([\d]+)/ /threads/$1?page=$2 [L,R=301]
    RewriteRule t([\d]+)/ /threads/$1 [L,R=301]
    RewriteRule f([\d]+)-([\d]+)/ /forums/$1?page=$2 [L,R=301]
    RewriteRule f([\d]+)/ /forums/$1 [L,R=301]
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
        #    line that begins "RewriteBase" below. You will also have to change the path
        #    of the rewrite to reflect the path to your XenForo installation.
        #RewriteBase /xenforo
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
    
     
    petertdavis likes this.
  9. Mian Shahid

    Mian Shahid Well-Known Member

    Hi, I have the same issue, when i used this code:
    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    #    cannot attach files, remove the "#" from the lines below.
    #<IfModule mod_security.c>
    #    SecFilterEngine Off
    #    SecFilterScanPOST Off
    #</IfModule>
    
    ErrorDocument 401 default
    ErrorDocument 403 default
    ErrorDocument 404 default
    ErrorDocument 500 default
    <IfModule mod_rewrite.c>
        RewriteEngine On
    
    RewriteRule t([\d]+)-([\d]+)/ /threads/$1?page=$2 [L,R=301]
    RewriteRule t([\d]+)/ /threads/$1 [L,R=301]
    RewriteRule f([\d]+)-([\d]+)/ /forums/$1?page=$2 [L,R=301]
    RewriteRule f([\d]+)/ /forums/$1 [L,R=301]
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
        #    line that begins "RewriteBase" below. You will also have to change the path
        #    of the rewrite to reflect the path to your XenForo installation.
        #RewriteBase /xenforo
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
    i found the following error in every thread link either from google search or from our forum.

    Code:
    Not Found
    
    The requested URL /usertag.php was not found on this server.
    
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e-fips mod_bwlimited/1.4 Server at www.itdarasgah.com Port 80
    i have an other code which also looks like un complete:

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    
    #    cannot attach files, remove the "#" from the lines below.
    
    #<IfModule mod_security.c>
    
    #    SecFilterEngine Off
    
    #    SecFilterScanPOST Off
    
    #</IfModule>
    
    
    
    ErrorDocument 401 default
    
    ErrorDocument 403 default
    
    ErrorDocument 404 default
    
    ErrorDocument 500 default
    
    
    
    <IfModule mod_rewrite.c>
    
        RewriteEngine On
    
    
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
    
        #    line that begins "RewriteBase" below. You will also have to change the path
    
        #    of the rewrite to reflect the path to your XenForo installation.
    
        #RewriteBase /xenforo
    
    
    
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    
    
        RewriteCond %{REQUEST_FILENAME} -f [OR]
    
        RewriteCond %{REQUEST_FILENAME} -l [OR]
    
        RewriteCond %{REQUEST_FILENAME} -d
    
        RewriteRule ^.*$ - [NC,L]
    
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    
        RewriteRule ^.*$ index.php [NC,L]
    
    that code re-directing to our new xenforo board but with the following error:

    Code:
    ITDarasgah - Pakistan's Largest IT Urdu Forum - Error
    The requested page could not be found.
    
    Kindly help.
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    @Ahtsham-Jutt

    I need an example old and new URL for a thread. Then I can create rewrites for you.
     
    Mian Shahid likes this.
  11. Mian Shahid

    Mian Shahid Well-Known Member

    @Jake Bunce

    Code:
    VB Board Link
    http://www.itdarasgah.com/showthread.php?132969
    
    Still available for view
    http://www.itdarasgah.com/oldvb/showthread.php?132969
    
    Available at Xenforo
    http://www.itdarasgah.com/threads/132969/
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    @Ahtsham-Jutt

    Add these rules to the top of the .htaccess file in your web root:

    Code:
    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)$
    RewriteRule ^(oldvb/)?showthread\.php$ /threads/%2/? [R=301,L]
    
     
    ARSamo and Mian Shahid like this.
  13. Mian Shahid

    Mian Shahid Well-Known Member

    @Jake Bunce

    Thanks

    This one is my current .htaccess
    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    
    #    cannot attach files, remove the "#" from the lines below.
    
    #<IfModule mod_security.c>
    
    #    SecFilterEngine Off
    
    #    SecFilterScanPOST Off
    
    #</IfModule>
    
    
    
    ErrorDocument 401 default
    
    ErrorDocument 403 default
    
    ErrorDocument 404 default
    
    ErrorDocument 500 default
    
    
    
    <IfModule mod_rewrite.c>
    
        RewriteEngine On
    
    
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
    
        #    line that begins "RewriteBase" below. You will also have to change the path
    
        #    of the rewrite to reflect the path to your XenForo installation.
    
        #RewriteBase /xenforo
    
    
    
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    
    
        RewriteCond %{REQUEST_FILENAME} -f [OR]
    
        RewriteCond %{REQUEST_FILENAME} -l [OR]
    
        RewriteCond %{REQUEST_FILENAME} -d
    
        RewriteRule ^.*$ - [NC,L]
    
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    
        RewriteRule ^.*$ index.php [NC,L]
    can i put provided code at top of this file?

    Waiting..............
    i tried to use only your provided line in .htaccess but the following occurred
    [​IMG]
     
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes.

    Please paste the entire .htaccess file that is causing the error. That error usually indicates a typo or some bad rule.
     
    Mian Shahid likes this.
  15. Mian Shahid

    Mian Shahid Well-Known Member

    @Jake Bunce
    Thanks Jake, Its working fine. :)

    Can I upload my current working .thaccess file for your review?
     
  16. Mian Shahid

    Mian Shahid Well-Known Member

    @Jake Bunce
    kindly favor me again and re write the .thaccess again with the following link
    Code:
    VB link
    http://www.itdarasgah.com/showthread.php?133889-Sovled-my-problem
    
    XF linnk
    http://www.itdarasgah.com/threads/sovled-my-problem.133889/
    
    Available link
    http://www.itdarasgah.com/oldvb/showthread.php?133889-Sovled-my-problem
    before, we did not included the thread name along with thread number, therefor, links with thread name not opening in XF board
     
  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    @Ahtsham-Jutt

    Add these rules to the top of the .htaccess file in your web root (to replace the previous rules I posted):

    Code:
    RewriteEngine On
    
    RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)(-|$)
    RewriteRule ^(oldvb/)?showthread\.php$ /threads/%2/? [R=301,L]
    
     
    ARSamo and Mian Shahid like this.
  18. Mian Shahid

    Mian Shahid Well-Known Member

    Thanks Jake, every thing is working :D
     
  19. Mian Shahid

    Mian Shahid Well-Known Member

    Hi, @Jake Bunce

    Unfortunately our site deleted completely due to some database query issues and lost everything.

    Now we update all things again but the .thaccess remaining pending, so kindly once again provide help regarding this issue

    our current .htaccess file is:

    Code:
    #    Mod_security can interfere with uploading of content such as attachments. If you
    
    #    cannot attach files, remove the "#" from the lines below.
    
    #<IfModule mod_security.c>
    
    #    SecFilterEngine Off
    
    #    SecFilterScanPOST Off
    
    #</IfModule>
    
    
    
    ErrorDocument 401 default
    
    ErrorDocument 403 default
    
    ErrorDocument 404 default
    
    ErrorDocument 500 default
    
    
    
    <IfModule mod_rewrite.c>
    
        RewriteEngine On
    
    
    
        #    If you are having problems with the rewrite rules, remove the "#" from the
    
        #    line that begins "RewriteBase" below. You will also have to change the path
    
        #    of the rewrite to reflect the path to your XenForo installation.
    
        #RewriteBase /xenforo
    
    
    
        #    This line may be needed to enable WebDAV editing with PHP as a CGI.
    
        #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
    
    
        RewriteCond %{REQUEST_FILENAME} -f [OR]
    
        RewriteCond %{REQUEST_FILENAME} -l [OR]
    
        RewriteCond %{REQUEST_FILENAME} -d
    
        RewriteRule ^.*$ - [NC,L]
    
        RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    
        RewriteRule ^.*$ index.php [NC,L]
    
    </IfModule>
    examples of VB & XF links:

    Code:
    VB link
    http://www.itdarasgah.com/showthread.php?2-welcome-to-itdarasgah-com
    
    XF link
    http://www.itdarasgah.com/threads/welcome-to-itdarasgah-com.2/
    Unfortunately no running VB installation is available.

    Waiting . . . . .
     
  20. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Mian Shahid and ARSamo like this.

Share This Page