homepage Welcome to WebmasterWorld Guest from 54.211.97.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Code blocked
htaccess on subdomain is blocked by main domain.
mircea1st



 
Msg#: 4059834 posted 1:58 pm on Jan 13, 2010 (gmt 0)

Hi everyone.

I have two scripts installed with a .htaccess file each, one script on the main domain , the other in a folder.
www.site.com
www.site.com/blog
Tha htaccess file from the main domain is blocking the htaccess file from subdomain . I got the ideea from someone that i should add new lines in the htaccess from the main domain:
RewriteEngine on

Options +FollowSymlinks

RewriteCond %{REQUEST_FILENAME} !-f

++
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ navigation.php

++
RewriteRule .* - [E=HTTP_X_REQUESTED_WITH:%{HTTP:X-Requested-With}]

Where ++ is i should add some extra code .
Please help me on what that code should be .

 

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4059834 posted 5:32 pm on Jan 13, 2010 (gmt 0)

Exclude the blog subdirectory from the top-level .htaccess file rewrite rule:

RewriteCond $1 !blog/

You should also exclude "navigation.php" itself from that rule. Doing so will approximately double the speed of that rule, which is very slow since it has to go check the filesystem four times as it is now:

RewriteCond $1 !navigation\.php$

Move the "[E=" rule to the top, and then add an [L] flag to all the following rules.

Jim

mircea1st



 
Msg#: 4059834 posted 7:08 pm on Jan 13, 2010 (gmt 0)

Hi Jim .

The way it looks after i did the changes :

RewriteEngine on
Options +FollowSymlinks

RewriteRule .* - [E=HTTP_X_REQUESTED_WITH:%{HTTP:X-Requested-With}]
RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond $1 !blog/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !navigation\.php$

If i put [L] to the last 4 rules at the end it will give me a """Error 500:Internal Server Error """
The way it is now it's kind of the same as before . I must not be following your instructions as i should.
Please tell me what can i change .
Thank you Jim.

Mircea.

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4059834 posted 7:36 pm on Jan 13, 2010 (gmt 0)

> If i put [L] on the last 4 rules at the end it gives me a "500-Internal Server Error"

There are only two rules in this file. The code should now look like this:

Options +FollowSymlinks
RewriteEngine on
#
# Copy HTTP "X-Requested-With" header to similarly-named server variable
RewriteRule .* - [E=HTTP_X_REQUESTED_WITH:%{HTTP:X-Requested-With}]
#
# Rewrite all requests for URL-paths which do not resolve to existing files or directories to
# "/navigation.php", except for /blog requests and internal requests for "/navigation.php" itself
RewriteCond $1 !^navigation\.php$
RewriteCond $1 !^blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ navigation.php [L]

Jim

mircea1st



 
Msg#: 4059834 posted 8:10 pm on Jan 13, 2010 (gmt 0)

It will still take me to a PAGE NOT FOUND
I did copy and paste of all the stuff above maybe it's because of something else.
Thanks so much JIM.
You think it's a different problem ?

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4059834 posted 8:15 pm on Jan 13, 2010 (gmt 0)

Did you clear/delete the browser cache before testing again?

What does "Live HTTP Headers" return for the test URL?

mircea1st



 
Msg#: 4059834 posted 8:29 pm on Jan 13, 2010 (gmt 0)

I did the refresh and i get :
blog/not_found.html
I am checking out some other post here and testing , no results though.

mircea1st



 
Msg#: 4059834 posted 8:32 pm on Jan 13, 2010 (gmt 0)

I'm sorry was i supposed to leave this part as it is or change something ?
# Copy HTTP "X-Requested-With" header to similarly-named server variable
RewriteRule .* - [E=HTTP_X_REQUESTED_WITH:%{HTTP:X-Requested-With}]
#

mircea1st



 
Msg#: 4059834 posted 8:57 pm on Jan 13, 2010 (gmt 0)

I found this one , for others worked ...
It seems different from the way my rules are.

<rewrite url=".*/blog/(.+)" to="$1" processing="stop" />

mircea1st



 
Msg#: 4059834 posted 9:37 pm on Jan 13, 2010 (gmt 0)

Ok.
So i got what you wrote above in domain .htaccess and added # RewriteBase /
And in the other subdomain i added: RewriteBase /blog/
And that was it.
Thanks soo much for your time Jim.
Cheers.
Mircea

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved