vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   .htaccess rules redirects (https://vborg.vbsupport.ru/showthread.php?t=306281)

katie hunter 12-25-2013 05:12 PM

.htaccess rules redirects
 
Hi, I liked to redirect my non www. urls of my homepage to the www. urls

Ex http://nihonomaru.com/ should redirect to http://www.nihonomaru.com/

However, when i applied this rule to the .htaccess

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

It is working but now on my forum, where i host my images on lightspeed, img1 subdomain, the images aren't appearing because they also get redirected i.e., img1 gets redirected to www.img1

See http://img1.nihonomaru.com/lighttpd/...edals/1231.gif

How can i apply an exclusion rule so the redirect doesn't not affect sub-domains? Or for only to apply the redirect for the homepage pages only?

Code:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/forum/(.*)
RewriteCond %{REQUEST_URI} !^/img1/(.*)
RewriteCond %{REQUEST_URI} !^/cache/(.*)
RewriteCond %{REQUEST_URI} !^/lighttpd/(.*)

RewriteCond %{REQUEST_URI} !^forum\.nihonomaru\.com
RewriteCond %{REQUEST_URI} !^img1\.nihonomaru\.com
RewriteCond %{REQUEST_URI} ^/chan.*
RewriteRule (.*) - [L]

RewriteCond %{REQUEST_URI} "/lighttpd/"
RewriteRule (.*) $1 [L]

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !^img1\.nihonomaru\.com
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?nihonomaru.com$
RewriteRule ^$ public/ [L]

RewriteCond %{HTTP_HOST} ^(www\.)?nihonomaru.com$
RewriteRule (.*) public/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

</IfModule>


vBNinja 12-25-2013 06:11 PM

Try
Code:

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

That will only work for urls that start with "img1", if you have url's that start with a dynamic digit let me know so i can fix it

katie hunter 12-25-2013 08:07 PM

Hi vBNinja,

I added it to my .htaccess but I see an internal server error message.

Quote:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
This is my current entire rules:

Code:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/forum/(.*)
RewriteCond %{REQUEST_URI} !^/cache/(.*)

RewriteCond %{REQUEST_URI} !^forum\.nihonomaru\.com
RewriteCond %{REQUEST_URI} ^/chan.*
RewriteRule (.*) - [L]

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


RewriteCond %{HTTP_HOST} ^(www\.)?nihonomaru.com$
RewriteRule ^$ public/ [L]

RewriteCond %{HTTP_HOST} ^(www\.)?nihonomaru.com$
RewriteRule (.*) public/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

</IfModule>


final kaoss 12-25-2013 11:56 PM

Here you go.

Code:

### BEGIN CLOUDFLARE REWRITE (domainB.com to www.domainB)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
### END CLOUDFLARE REWRITE ###################


katie hunter 12-26-2013 01:06 AM

Quote:

Originally Posted by final kaoss (Post 2470559)
Here you go.

Code:

### BEGIN CLOUDFLARE REWRITE (domainB.com to www.domainB)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
### END CLOUDFLARE REWRITE ###################



Hi, why identifying it as specifically redirect everything on port 80 to the http URL?

Max Taxable 12-26-2013 01:19 AM

Side Note: You have a 404 missing or incorrectly named image here:
HTML Code:

URL: http://forum.nihonomaru.com/images/styles/OrangeTheme/style/headerBG.gif
Host: forum.nihonomaru.com
IP: 141.101.117.217
Location: Cloudflare
Error/Status Code: 404
Client Port: 56304
Start Offset: 1.308 s
Time to First Byte: 39 ms
Content Download: 0 ms
Bytes In (downloaded): 0.6 KB
Bytes Out (uploaded): 0.6 KB


final kaoss 12-26-2013 01:51 AM

Not too sure if that matters too much but that's what I've come up with after browsing through several tutorials & articles.

Also I realize that this plugin is a vb3 plugin but it still seems to get the job done in vb4 as well (I've used it for a couple of years now).
https://vborg.vbsupport.ru/showthread.php?t=222898
Quote:

Originally Posted by katie hunter (Post 2470570)
Hi, why identifying it as specifically redirect everything on port 80 to the http URL?


katie hunter 12-26-2013 03:16 AM

Quote:

Originally Posted by Max Taxable (Post 2470573)
Side Note: You have a 404 missing or incorrectly named image here:
HTML Code:

URL: http://forum.nihonomaru.com/images/styles/OrangeTheme/style/headerBG.gif
Host: forum.nihonomaru.com
IP: 141.101.117.217
Location: Cloudflare
Error/Status Code: 404
Client Port: 56304
Start Offset: 1.308 s
Time to First Byte: 39 ms
Content Download: 0 ms
Bytes In (downloaded): 0.6 KB
Bytes Out (uploaded): 0.6 KB


It is embed correctly in here http://forum.nihonomaru.com/azskinz/...e/headerBG.gif

I can't seem to find where this url is in the template.

Code:

#headerMain {
    background: url(azskinz/nihonomaru/style/headerBG.gif) repeat-x scroll left top transparent;
    height: 96px;
    padding: 0 20px;
    position: relative;
}

Quote:

Originally Posted by final kaoss (Post 2470575)
Not too sure if that matters too much but that's what I've come up with after browsing through several tutorials & articles.

Also I realize that this plugin is a vb3 plugin but it still seems to get the job done in vb4 as well (I've used it for a couple of years now).
https://vborg.vbsupport.ru/showthread.php?t=222898

I prefer if i don't use any weird plugin's for this, usually .htaccess works + this is outdated i mean it works for vb 3.8 not 4.x.

I don't really have an issue with my forum url, it is working perfectly, my issue is for the sub domain img1 which is lightspeed that is hosting my forum images.

final kaoss 12-26-2013 03:32 AM

Sorry about that, been posting while I'm half awake over here.

Try this solution.
http://stackoverflow.com/questions/1...ailing-slashes

katie hunter 12-26-2013 04:04 AM

We can check it tomorrow :) thanks for your help!

I tried it but it didn't work:

Code:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/forum/(.*)
RewriteCond %{REQUEST_URI} !^/cache/(.*)

RewriteCond %{REQUEST_URI} !^forum\.nihonomaru\.com
RewriteCond %{REQUEST_URI} ^/chan.*
RewriteRule (.*) - [L]

#Force www.
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^nihonomaru\.com$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


RewriteCond %{HTTP_HOST} ^(www\.)?nihonomaru.com$
RewriteRule ^$ public/ [L]

RewriteCond %{HTTP_HOST} ^(www\.)?nihonomaru.com$
RewriteRule (.*) public/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

</IfModule>


I also added this part as well and it didn't work, unless i did something wrong

Code:

#Remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^(.+)/$ /$1 [R=301,L]



All times are GMT. The time now is 03:20 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.01655 seconds
  • Memory Usage 1,757KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (2)bbcode_html_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete