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

XF 1.4 2 different urls with one forum

clove28

Active member
#1
Hi everyone,

I just noticed that I can access www.pinoyexpatforum.com and also pinoyexpatforum.com as they are. So when I type "www.pinoyexpatforum.com", it shows exactly as that in the url. And that also goes to "pinoyexpatfurum.com". So while I'm logged-in with the other url, I'm log-out from the other with the same browser. What could be the problem?
 

clove28

Active member
#4
See the FAQ in my signature for how to force it to one or the other.
The code needed is already in placed. But I think I messed up. Here's my 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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 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>

Header unset Pragma
FileETag None
Header unset ETag

# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS 172800
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=604800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Dec 2011 20:00:00 GMT"
</FilesMatch>

RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)f=([0-9]+)&t=([0-9]+)($|&)
RewriteRule ^viewtopic\.php$ /index.php?threads/%3/ [R=301,L]

RewriteCond %{QUERY_STRING} (^|\?)f=([0-9]+)($|&)
RewriteRule ^viewforum\.php$ /index.php?forums/%2/ [R=301,L]

# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
## EXPIRES CACHING ##

<IfModule mod_expires.c>

# Enable expirations
ExpiresActive On

# Default directive
ExpiresDefault "access plus 1 month"

# My favicon
ExpiresByType image/x-icon "access plus 1 year”

# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"

# CSS
ExpiresByType text/css "access 1 month”

# Javascript
ExpiresByType application/javascript "access plus 1 year"

</IfModule>

## EXPIRES CACHING ##
#<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#</IfModule>

<Files "config.php">
Order Allow,Deny
Deny from All
</Files>

<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
DirectoryIndex portal.php index.php index.html index.htm
<IfModule mod_rewrite.c>
RewriteEngine on

Rewriterule ^blog/(.+)/(.+).html$        ./blog/view/blog.php?page=$1&mode=$2 [NC]
Rewriterule ^blog/(.+).html$            ./blog/blog.php?page=$1 [NC]
Rewriterule ^blog/(.+)/$                ./blog/view/blog.php?page=$1 [NC]
Rewriterule ^blog/$                        ./blog/blog.php [NC]

RewriteCond %{REQUEST_FILENAME} !-f
Rewriterule ^blog/(.+)/(.+)$        ./blog/view/blog.php?page=$1&mode=$2 [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^blog/(.+)$ ./blog/blog.php?page=$1 [NC]
</IfModule>

RewriteCond %{HTTP_REFERER} !^http://pinoyexpatforum.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://pinoyexpatforum.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.pinoyexpatforum.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.pinoyexpatforum.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]


# Start CloudFlare:pinoyexpatforum.com rewrite. Do not Edit
RewriteEngine On
RewriteCond %{HTTP_HOST} ^pinoyexpatforum.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# End CloudFlare rewrite.
 

Brogan

XenForo moderator
Staff member
#5
That file is a mess - I see RewriteEngine on at least three times.

Also, any custom rewrites must come before the XF rewrites.
 

clove28

Active member
#6
That file is a mess - I see RewriteEngine on at least three times.

Also, any custom rewrites must come before the XF rewrites.
That's what I thought..:D So do I just need to put the default xenforo at the last part? And about the RewriteEngine on, how can I delete the other RewriteEngine on without affecting its function?
 

clove28

Active member
#8
Once you have declared RewriteEngine on, it doesn't need to be re-declared later in the file.

This is the default .htaccess file: https://xenforo.com/community/htaccess.txt

I would recommend starting with that and adding what you need.
Is this okay now?

Code:
Header unset Pragma
FileETag None
Header unset ETag

# 1 YEAR
<FilesMatch "\.(ico|pdf|flv)$">
Header set Cache-Control "max-age=29030400, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 2 DAYS 172800
<FilesMatch "\.(xml|txt|css|js)$">
Header set Cache-Control "max-age=604800, proxy-revalidate"
</FilesMatch>
# 1 MIN
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=60, private, proxy-revalidate"
</FilesMatch>

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Dec 2011 20:00:00 GMT"
</FilesMatch>

RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)f=([0-9]+)&t=([0-9]+)($|&)
RewriteRule ^viewtopic\.php$ /index.php?threads/%3/ [R=301,L]

RewriteCond %{QUERY_STRING} (^|\?)f=([0-9]+)($|&)
RewriteRule ^viewforum\.php$ /index.php?forums/%2/ [R=301,L]

# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
## EXPIRES CACHING ##

<IfModule mod_expires.c>

# Enable expirations
ExpiresActive On

# Default directive
ExpiresDefault "access plus 1 month"

# My favicon
ExpiresByType image/x-icon "access plus 1 year”

# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"

# CSS
ExpiresByType text/css "access 1 month”

# Javascript
ExpiresByType application/javascript "access plus 1 year"

</IfModule>

## EXPIRES CACHING ##
#<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#</IfModule>

<Files "config.php">
Order Allow,Deny
Deny from All
</Files>

<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
DirectoryIndex portal.php index.php index.html index.htm
<IfModule mod_rewrite.c>
RewriteEngine on

Rewriterule ^blog/(.+)/(.+).html$        ./blog/view/blog.php?page=$1&mode=$2 [NC]
Rewriterule ^blog/(.+).html$            ./blog/blog.php?page=$1 [NC]
Rewriterule ^blog/(.+)/$                ./blog/view/blog.php?page=$1 [NC]
Rewriterule ^blog/$                        ./blog/blog.php [NC]

RewriteCond %{REQUEST_FILENAME} !-f
Rewriterule ^blog/(.+)/(.+)$        ./blog/view/blog.php?page=$1&mode=$2 [NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^blog/(.+)$ ./blog/blog.php?page=$1 [NC]
</IfModule>

RewriteCond %{HTTP_REFERER} !^http://pinoyexpatforum.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://pinoyexpatforum.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.pinoyexpatforum.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.pinoyexpatforum.com$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]


# Start CloudFlare:pinoyexpatforum.com rewrite. Do not Edit
RewriteCond %{HTTP_HOST} ^pinoyexpatforum.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# End CloudFlare rewrite.

#    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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.

    #    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>