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

Need help redirect url

#1
I converted my vb4 forum to xf a week ago, thread & forums url redirecting works perfect, I need help in redirection some other urls.
My xf is installed in "mysite.com/community/" folder, I have php 5.3.3, Apache 2.2.16, Debian squeeze.

1- I want to redirect all www to non-www. I found this in searching here:
Code:
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Is it good for my case ?


2- Nothing is installed in my site homepage "mysite.com/", I want to redirect this page to my xenporta page: http://mysite.com -----> http://mysite.com/community/portal/

3- My old vb4 forum was installed in "mysite.com/forums/" folder, all thread and forums urls redirecting works great, except the vb home page. I want this redirect: http://mysite.com/forums/ -----> http://mysite.com/community/

4- I have static content located in "mysite.com/quran" folder: http://mysite.com/quran/ as a home page for this static content, and http://mysite.com/quran/page1.html, http://mysite.com/quran/page2.html, ... as different pages for that content.
Now I have transferred this content using xf pages system, so I want these redirects:
http://mysite.com/quran/ ----------------> http://mysite.com/community/pages/quran/
http://mysite.com/quran/page1.html ---> http://mysite.com/community/pages/quran/page1/
http://mysite.com/quran/page2.html ---> http://mysite.com/community/pages/quran/page2/
....
http://mysite.com/quran/page18.html ---> http://mysite.com/community/pages/quran/page18/


Thank you.
 

Jake Bunce

XenForo moderator
Staff member
#2
1) To enforce no "www" in the /community directory, add these two lines to XenForo's .htaccess file in the /community directory:

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

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

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

Jake Bunce

XenForo moderator
Staff member
#3
2) You can upload an "index.php" file to the web root with this:

Code:
<?php

header("Location: http://mysite.com/community/portal/");

?>
3) Similar to #2.

4) Use this .htaccess file in the /quran directory:

Code:
RewriteEngine On

RewriteRule ^page([0-9]+)\.html$ /community/pages/quran/page$1/ [R=301,L]
RewriteRule ^$ /community/pages/quran/ [R=301,L]
 
#4
Thank you Jake. That works great.

About the 4th point, page's names are not page1, page2, ... I did that just to explain that there are many pages.
Page's names are like: affasi.html, sudays.html, ... so the redirects shoul be:
http://mysite.com/quran/affasi.html ---> http://mysite.com/community/pages/quran/affasi/
http://mysite.com/quran/sudays.html ---> http://mysite.com/community/pages/quran/sudays/
....
Please update the last code.
Sorry for that.