URL rewriting interfering with another app?

Creating and modifying plugins.
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

URL rewriting interfering with another app?

Post by Hathor »

I have a text counter program on my blog that I should be able to access at:

http://www.thehathorlegacy.info/L10Apps ... orter.html

But since I changed the URL rewriting yesterday, it's redirecting that page to the main page of the blog. I don't understand the .htaccess code well enough to know what I can modify and what I can't. Do you have any idea what's causing it, and is there a workaround?

Here's the .htaccess code



# BEGIN s9y
ErrorDocument 404 /index.php
DirectoryIndex /index.php
php_value session.use_trans_sid 0
php_value register_globals off

RewriteEngine On
RewriteBase /
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^(admin|entries)(/.+)? index.php?url=admin/ [L,QSA]
RewriteRule ^archive$ index.php?url=/archive [L,QSA]
RewriteRule ^categories/([0-9]+) index.php?url=/categories/$1 [L,QSA]
RewriteRule ^(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$ rss.php?file=$1&ext=$2
RewriteRule ^plugin/(.*) index.php?url=plugin/$1 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$1 [L,QSA]
RewriteRule ^authors/([0-9]+) index.php?url=/authors/$1 [L,QSA]
RewriteRule ^index\.(html?|php.?) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]

<Files *.tpl>
deny from all
</Files>

<Files *.sql>
deny from all
</Files>

<Files *.inc.php>
deny from all
</Files>

<Files *.db>
deny from all
</Files>

# END s9y


RewriteRule ^pagetitle serendipity[subpage]=pagetitle
RewriteRule ^static/(.*) serendipity[subpage]=$1
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

I just found it's doing the same thing on my other blog. As far as I can tell, it's redirecting ANY file with an .html ending to the main page.

The htaccess in both files is the same.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Yes, this is intentional behavior.

You should not install other applications into the Serendipity directory, place it outside a directory. The redirection is necessary to define any custom permalink ending on '.html'.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

The misbehaving pages ARE in separate directories. See the URL I posted. S9 is in the root folder on both blogs, and the other apps are in separate directories.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

But they are in subdirectories, right? You need to put the files outside the whole s9y tree...

You cannot have it that way when s9y is in the root folder of your webpage.

You can put a .htaccess file iny our subdirectories containing the files and try this:

Code: Select all

RewriteEngine Off
Alternatively, remove this line from your .htaccess:

Code: Select all

RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA] 
Note that you will then loose the possibility of custom permalinks via the custompermalink event plugin...

Regards and good luck,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

garvinhicking wrote:You can put a .htaccess file iny our subdirectories containing the files and try this:

Code: Select all

RewriteEngine Off
That worked like a charm. Now I can put it in any subdirectory that needs it. Thank you! :)
kuhlhost
Posts: 1
Joined: Wed Aug 03, 2005 2:26 am
Contact:

statistic packages

Post by kuhlhost »

I'm posting this simply for other users who may wonder why their webalizer, awstats or modlogan isn't working if they put serendipity into their root directory. If your site is hosted on a shared server with one of these stats packages you will need to put an .htaccess into the stats directory as per garvinhickings advice.
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

I have a new version of this same problem.

I have a subfolder of straight html files under my Hathor blog. In order to get those pages to load, I have to put an htaccess with "rewriteengine off" in it.

But there's a feature of rewriting that I NEED in that subfolder - I need to redirect urls using a "www" to a non-www version. For example, if someone types

"http://www.thehathorlegacy.info/example/index.html"

I want to use a 301 redirect to make it instead load:

"http://thehathorlegacy.info/example/index.html"

This may seem ridiculous, but it's important for ranking in Google.

Can you make any suggestions? I tried turning off that line of permalinks code as you also suggested, and none of my permalinks would work anymore, which is even WORSE from a Google perspective. :D

Is there a way to turn off S9's rewrite code in the subfolder, but still keep the 301 redirect for www urls?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

You will need to put each rewriteRule of s9y's .htaccess into the .htaccess of your subfolder, but then use the right paths (instead of "index.php" you will need to use "/index.php" or something like that). Then only omit this rewriteRule in your subfolders .htaccess:

Code: Select all

RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA] 
and change it to

Code: Select all

RewriteRule (.*\.html?) $1 [L,QSA] 
Also change any other rewriterule that your subfolder might catch (like if the subfolder is called "archive" or something like that.

Regard,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

I don't think I quite understood that, because what I tried to do didn't work. I copied all the rewrite rules from the main htaccess to the subfolder htaccess. Then I put the directory name in slashes ahead of each "index.php" so they became "/[subfolder]/index.php".

Is that wrong, or is it something else that's screwy?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Please post your full .htaccess here, then I can look at it. Also tell me the pathname you installed s9y into, and the pathname of where this .htaccess is stored by you. :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

Path is /home/thehatho/public_html/ - it's installed into the main directory, not a subfolder. So that's where both the htaccess and all S9 files are.

Htaccess would be at /home/thehatho/public_html/.htaccess (http://thehathorlegacy.info/.htaccess)

Here's the htaccess code - sorry, there may be some junk in there right now b/c I've been messing with it.
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^thehathorlegacy\.info$
RewriteRule (.*) http://thehathorlegacy.info/$1 [R=301,L]

# BEGIN s9y
# ErrorDocument 404 /index.php
# DirectoryIndex /index.php

RewriteBase /
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^(admin|entries)(/.+)? index.php?url=admin/ [L,QSA]
RewriteRule ^archive$ index.php?url=/archive [L,QSA]
RewriteRule ^categories/([0-9]+) index.php?url=/categories/$1 [L,QSA]
RewriteRule ^(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$ rss.php?file=$1&ext=$2
RewriteRule ^plugin/(.*) index.php?url=plugin/$1 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$1 [L,QSA]
RewriteRule ^authors/([0-9]+) index.php?url=/authors/$1 [L,QSA]
RewriteRule ^index\.(html?|php.?) index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) index.php?url=/$1 [L,QSA]

<Files *.tpl>
deny from all
</Files>

<Files *.sql>
deny from all
</Files>

<Files *.inc.php>
deny from all
</Files>

<Files *.db>
deny from all
</Files>

# END s9y


RewriteRule ^pagetitle serendipity[subpage]=pagetitle
RewriteRule ^static/(.*) serendipity[subpage]=$1

# <Files 403.shtml>
# order allow,deny
# allow from all
# </Files>

# RedirectMatch permanent ^/rss.php$
# http://thehathorlegacy.info/feeds/index.rss2

deny from 72.36.150.4
deny from 64.156.213.228
deny from 72.36.150.3
deny from 66.198.36.17
deny from 72.36.150.5
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Okay. Now say your subdirectory is /home/thehatho/public_html/mysubdir - then put this .htaccess file there:

Code: Select all

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

# BEGIN s9y
# ErrorDocument 404 /index.php
# DirectoryIndex /index.php

RewriteBase /
RewriteRule ^archives([/A-Za-z0-9]+)\.html /index.php?url=/archives/$1.html [L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html /index.php?url=$1-article.html [L,NC,QSA]
RewriteRule ^feeds/(.*) /index.php?url=/feeds/$1 [L,QSA]
RewriteRule ^unsubscribe/(.*)/([0-9]+) /index.php?url=/unsubscribe/$1/$2 [L,QSA]
RewriteRule ^approve/(.*)/(.*)/([0-9]+) /index.php?url=approve/$1/$2/$3 [L,QSA]
RewriteRule ^delete/(.*)/(.*)/([0-9]+) /index.php?url=delete/$1/$2/$3 [L,QSA]
RewriteRule ^(admin|entries)(/.+)? /index.php?url=admin/ [L,QSA]
RewriteRule ^archive$ /index.php?url=/archive [L,QSA]
RewriteRule ^categories/([0-9]+) /index.php?url=/categories/$1 [L,QSA]
RewriteRule ^(index|atom|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)$ /rss.php?file=$1&ext=$2
RewriteRule ^plugin/(.*) /index.php?url=plugin/$1 [L,QSA]
RewriteRule ^search/(.*) /index.php?url=/search/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) /index.php?url=/$1 [L,QSA]
RewriteRule ^authors/([0-9]+) /index.php?url=/authors/$1 [L,QSA]
RewriteRule ^index\.(html?|php.?) /index.php?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) /htmlarea/$1 [L,QSA]
RewriteRule (.*\.html?) $1 [L,QSA]

<Files *.tpl>
    deny from all
</Files>

<Files *.sql>
    deny from all
</Files>

<Files *.inc.php>
    deny from all
</Files>

<Files *.db>
    deny from all
</Files>

# END s9y


RewriteRule ^pagetitle serendipity[subpage]=pagetitle
RewriteRule ^static/(.*) serendipity[subpage]=$1 

# <Files 403.shtml>
# order allow,deny
# allow from all
# </Files>

# RedirectMatch permanent ^/rss.php$  
# http://thehathorlegacy.info/feeds/index.rss2

deny from 72.36.150.4
deny from 64.156.213.228
deny from 72.36.150.3
deny from 66.198.36.17
deny from 72.36.150.5
Hope this works. I'm not terribly good at rewriteRules and don't know how exactly and in which order they are executed if two .htaccess files match...

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Hathor
Regular
Posts: 118
Joined: Tue Mar 22, 2005 11:48 pm

Post by Hathor »

No, that takes the www out of the URL window just fine... but then it reroutes to my home page. Example:

If you type

http://www.thehathorlegacy.info/mysubdir/example.html

The url in the bar will change to:

http://thehathorlegacy.info/mysubdir/example.html

But the page in the browser window will be

http://thehathorlegacy.info/index.php

:sigh: :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Maybe you can then just make a rewriteRule in your central .htaccess that makes a "and url NOT like /mysubdir/". Don't know how currently, but I know it's possible by using some "!" and "RewriteCond" things.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply