Page 1 of 1

Help on Mod_Rewrite rule for .HTACCESS

Posted: Thu Sep 13, 2007 3:32 pm
by digitalfilm
Serendipity is installed in the root directory. I would like to publish all static pages to the root, and create a rewrite rule so that all blog postings SEEM to be in the /blog/ subdirectory (makes it easier for clients and SEO).

However, I cannot seem to figure out how to do this, no matter how much I read. Can anyone offer a suggestion. My .HTACCESS file is below. Thanks!


-----------------------------------------
## password begin ##
AuthUserFile /usr/www/users/mh8020/.passwd
AuthName "Protected"
AuthType Basic
<Limit GET POST PUT>
require valid-user
</Limit>
<Files .passwd>
deny from all
</Files>
## password end ##
# BEGIN s9y
ErrorDocument 404 /mh8020/index.php
DirectoryIndex /mh8020/index.php
php_value session.use_trans_sid 0
php_value register_globals off

RewriteEngine On
RewriteBase /mh8020/
RewriteRule ^((archives/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [NC,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 ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2
RewriteRule ^(plugin|plugin)/(.*) index.php?url=$1/$2 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^comments/(.*) index.php?url=/comments/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$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.php>
deny from all
</Files>

<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

IndexIgnore *
--------------------------------

Re: Help on Mod_Rewrite rule for .HTACCESS

Posted: Fri Sep 14, 2007 11:31 am
by garvinhicking
Hi!

This is actually pretty easy! Just enter "/blog/blabla.html" for the permalink of each of your static pages. :-)

However, your .htaccess file tells that s9y is not installed in the root, but in a directory "/mh8020", is that right?

Regards,
Garvin

actually backwards

Posted: Fri Sep 14, 2007 3:38 pm
by digitalfilm
it turns out my new apache installation does not support rewrites -- or that i don't understand them -- so this may be a moot point. when i click on a posting with an internal link to say /downloads/hello-world.pdf i get redirected to the front page.

So given all that, would i be correct in saying it is not possible to put all blog posts in /blog and all static pages in /pages/blahbah.html.?

(the mh8020 thing was just the development server, and serendipity is now installed and operational in the root)

Re: actually backwards

Posted: Sat Sep 15, 2007 10:30 am
by garvinhicking
Hi!
So given all that, would i be correct in saying it is not possible to put all blog posts in /blog and all static pages in /pages/blahbah.html.?
That's not correct. You can get it to work!

If you use your .htaccess above (with correct paths instead of mh8020) you CAN assign your static pages to the /pages subdirectory (by configuring each staticpages permalink, as mentioned). And you CAN adjust the s9y path to be changed from "/archives" to "/blog".

Then you can run serendipity via http://yourblog/ and view a page with htttp://yourblog/pages/staticpage.html and a blog entry with http://yourblog/blog/1-yourentry.html

Regards,
Garvin

Well I am still unable to get Screencams to load

Posted: Mon Sep 17, 2007 7:09 pm
by digitalfilm
Turning Apache rewrite back on makes it impossible for visitors to view screen cams. If you go to this link:

http://group8020.com/archives/30-How-To ... -Maps.html and click on the image, it will open a pop-up but not play the presentation. With rewrite OFF, it loads fine.

Here's my .htaccess with Rewrite turned on. Thanks!

---------------------------

# 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/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.html)/?) index.php?/$1 [NC,L,QSA]
RewriteRule ^(authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(feeds/authors/([0-9]+)-[0-9a-z\.\_!;,\+\-\%]+\.rss) index.php?/$1 [NC,L,QSA]
RewriteRule ^(categories/([0-9;]+)-[0-9a-z\.\_!;,\+\-\%]+) index.php?/$1 [NC,L,QSA]
RewriteRule ^archives([/A-Za-z0-9]+)\.html index.php?url=/archives/$1.html [NC,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 ^(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml) rss.php?file=$1&ext=$2
RewriteRule ^(plugin|plugin)/(.*) index.php?url=$1/$2 [L,QSA]
RewriteRule ^search/(.*) index.php?url=/search/$1 [L,QSA]
RewriteRule ^comments/(.*) index.php?url=/comments/$1 [L,QSA]
RewriteRule ^(serendipity\.css|serendipity_admin\.css) index.php?url=/$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.php>
deny from all
</Files>

<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

-----------------

Re: Well I am still unable to get Screencams to load

Posted: Mon Sep 17, 2007 7:38 pm
by garvinhicking
Hi!

Please read the FAQ on www.s9y.org for accessing .html files in custom subdirectories:

http://www.s9y.org/11.html#A13

Regards,
Garvin