• 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!

petertdavis

Well-known member
#1
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. :)
 

Jeremy

Well-known member
#2
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.
 

petertdavis

Well-known member
#3
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.
 

Jake Bunce

XenForo moderator
Staff member
#8
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>
 

Mian Shahid

Well-known member
#9
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.
 

Mian Shahid

Well-known member
#11
@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/
 

Mian Shahid

Well-known member
#13
@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
 

Mian Shahid

Well-known member
#16
@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
 

Mian Shahid

Well-known member
#19
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 . . . . .