"RewriteEngine On" and static pages

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: "RewriteEngine On" and static pages

Post by Lux »

Timbalu wrote:What do you mean by "Hm. Don't like ..." ??

This all is missing. This is the reason why you never have a successfull rewrite.
Oh, sorry, once I enable it via configuration I have all the items you mentioned, see below.

Don't like that .htacces in the root-directory for the domain overwrites the local one.

Cheers

Dirk

Code: Select all

# BEGIN s9y
ErrorDocument 404 /dirk/blog/index.php
DirectoryIndex /dirk/blog/index.php
php_value session.use_trans_sid 0
php_value register_globals off
Options -MultiViews

RewriteEngine On
RewriteBase /dirk/blog/
RewriteRule ^serendipity_admin.php serendipity_admin.php [NC,L,QSA]
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]
#RewriteCond %{REQUEST_URI} !-U
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
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: "RewriteEngine On" and static pages

Post by Timbalu »

What happens, when you enable the RewriteBase / rule in the roots htaccess?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: "RewriteEngine On" and static pages

Post by Lux »

Timbalu wrote:What happens, when you enable the RewriteBase / rule in the roots htaccess?
Exactly the same problem.

Dirk
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: "RewriteEngine On" and static pages

Post by Timbalu »

So - testwise -you should disable that root htaccess for a while, to see if the blog rules work correct with mode_rewrite ON.
Then we have to think about on how to restrict these root rules to the urls you need to redirect on there, I assume. These RewriteCond %{REQUEST_FILENAME} ... rules seem to be too wide open to stick to web root links only...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: "RewriteEngine On" and static pages

Post by Lux »

Timbalu wrote:So - testwise -you should disable that root htaccess for a while, to see if the blog rules work correct with mode_rewrite ON.
Then we have to think about on how to restrict these root rules to the urls you need to redirect on there, I assume. These RewriteCond %{REQUEST_FILENAME} ... rules seem to be too wide open to stick to web root links only...
I checked this with all eight blogs I work with.

The other blogs are either running in the root directory or do not have a .htaccess in the root directory of the domain. They have the same issues.

Cheers

Dirk
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: "RewriteEngine On" and static pages

Post by Timbalu »

Lux wrote:They have the same issues.
And this does mean, "they can not use mod_rewrite as the one and only issue"?
Is that all the same presence?
How exactly is that debian apache configured...? (related to MR)

SCNR ... You may read about it here http://www.amazon.de/exec/obidos/ASIN/3 ... omepa09-21 :mrgreen:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: "RewriteEngine On" and static pages

Post by Lux »

Timbalu wrote:
Lux wrote:They have the same issues.
And this does mean, "they can not use mod_rewrite as the one and only issue"?
Is that all the same presence?
How exactly is that debian apache configured...? (related to MR)
Exactly they can not use the configuration option for mod_rewrite, although it is enabled.

They are all on the same server, but not using the same domain.

Two examples for vHost-Configurations attached.

Code: Select all

09:08:16 [root@rico:/etc/apache2] # ls mods-enabled/
alias.conf            authz_host.load  deflate.load  mime.conf         proxy.conf       rewrite.load   status.load
alias.load            authz_user.load  dir.conf      mime.load         proxy_http.load  setenvif.conf  wsgi.conf
auth_basic.load       autoindex.conf   dir.load      negotiation.conf  proxy.load       setenvif.load  wsgi.load
authn_file.load       autoindex.load   env.load      negotiation.load  python.load      ssl.conf
authz_default.load    cgi.load         headers.load  php5.conf         reqtimeout.conf  ssl.load
authz_groupfile.load  deflate.conf     include.load  php5.load         reqtimeout.load  status.conf

09:08:47 [root@rico:/etc/apache2] # cat sites-enabled/deimhart.net 
<VirtualHost 217.11.53.135:80>

	ServerName deimhart.net
	DocumentRoot /srv/www/deimhart.net
        ErrorLog /var/log/apache2/deimhart.net/error.log
        CustomLog /var/log/apache2/deimhart.net/access.log combined

	RewriteEngine on
	RewriteCond %{HTTP_HOST}   !^$

	Redirect permanent /+ https://plus.google.com/108670723027854715905/posts
	Redirect permanent /itunes/DeimHart.xml http://deimhart.net/index.php?/feeds/index.rss2
	Redirect permanent /index.php?/feeds/categories/4-interna.rss http://deimhart.net/index.php?/feeds/index.rss2
	Redirect permanent /index.php?/feeds/categories/2-sendung-mp3.rss http://deimhart.net//rss.php?version=2.0&podcast_format=mp3
	Redirect permanent /index.php?/feeds/categories/3-sendung-ogg.rss http://deimhart.net//rss.php?version=2.0&podcast_format=ogg
	Redirect permanent /index.php?/feeds/categories/1-sendung-text.rss http://deimhart.net/index.php?/feeds/index.rss2
</VirtualHost>

<VirtualHost 217.11.53.135:80>
	ServerName sandhaut.net
	DocumentRoot /srv/www/sandhaut.net
        ErrorLog /var/log/apache2/sandhaut.net/error.log
        CustomLog /var/log/apache2/sandhaut.net/access.log combined
	RewriteEngine on
</VirtualHost>
Timbalu wrote:SCNR ... You may read about it here http://www.amazon.de/exec/obidos/ASIN/3 ... omepa09-21 :mrgreen:
:lol:

Dirk
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: "RewriteEngine On" and static pages

Post by Timbalu »

and rewrite.load loads mod_rewrite.so, I assume?

What about:
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
:?:

Sometimes this still sticks to be "AllowOverride None... "

Play around with that, since I am off until afternoon.... :wink:
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: "RewriteEngine On" and static pages

Post by Lux »

Timbalu wrote:and rewrite.load loads mod_rewrite.so, I assume?
Timbalu wrote:Exactly.

What about:
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
:?:

Sometimes this still sticks to be "AllowOverride None... "

Play around with that, since I am off until afternoon.... :wink:
No idea. Which settings would be appropriate?

We have national holiday today in Switzerland. So, I will be off as well.

Cheers

Dirk
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: "RewriteEngine On" and static pages

Post by Timbalu »

Lux wrote:No idea. Which settings would be appropriate?
The ones I posted ... ;-)
in the host settings in /etc/apache2/sites-available/default or where ever you have your host settings.

Like at least this for example... (adapted from one of mine... change for your situation)

Code: Select all

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

<VirtualHost *>
	DocumentRoot "/var/www/webXXX/html"
	ServerName example.de
	ServerAlias  www.example.de example.de
	php_admin_value open_basedir "/var/www/webXXX/:/usr/share/php:/var/www/fonts:/usr/bin:/usr/local/bin"
	php_value include_path ".:/usr/share/php/"
	php_admin_flag safe_mode Off
   ## suexec nur mit cgi modus
	##SuexecUserGroup webXXX www-data

	<Directory "/var/www/webXXX/html">
		DirectoryIndex index.html index.php
		Options +FollowSymLinks +Includes +Indexes +SymLinksIfOwnerMatch
		AllowOverride All
      Order allow,deny
		allow from all
		php_admin_flag safe_mode off
	</Directory>

	LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T %v" full
	ErrorLog /var/www/webXXX/log/example.de-error_log
	CustomLog /var/www/webXXX/log/example.de-access_log common
</VirtualHost>

Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: "RewriteEngine On" and static pages

Post by Timbalu »

Dirk, what happend to this issue? Did you get it to work? How?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Lux
Regular
Posts: 764
Joined: Fri Aug 12, 2005 4:36 pm
Location: Grüt, Zürich, Switzerland
Contact:

Re: "RewriteEngine On" and static pages

Post by Lux »

Timbalu wrote:Dirk, what happend to this issue? Did you get it to work? How?
No!

I changed it back to the original configuration, not using mod_rewrite.

Nevertheless the module is activated and configured on the Apache side, but not in Serendipity.

Cheers

Dirk
jlr
Regular
Posts: 34
Joined: Sat Feb 18, 2012 12:50 pm
Contact:

Re: "RewriteEngine On" and static pages

Post by jlr »

onli wrote:In the static pages settings, change the path of the page from /index.php?/page/... to /page; remove the index.php-part.
Regards
Bumping this old thread to say thank you and in case people are still googling for this problem, as I did.

I recently changed Configuration > Appearance > URL Rewriting from "Disable" to "Apache errorhandling" because else Facebook would destroy links to my blog (slashes in the URL were replaced by %2F). This very old thread was of help.

I must admit I don't know about the difference between errorhandling and mod_rewrite, but mod_rewrite would make my blog disappear, so I logged in with my FTP client, killed the .htaccess file, went back to config and changed the setting to errorhandling, which worked fine, except for static pages.

Now I manually changed the path of the pages as you suggested. All the old links are working again.
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: "RewriteEngine On" and static pages

Post by yellowled »

jlr wrote:I must admit I don't know about the difference between errorhandling and mod_rewrite, but mod_rewrite would make my blog disappear, so I logged in with my FTP client, killed the .htaccess file, went back to config and changed the setting to errorhandling, which worked fine, except for static pages.
The most likely explanation for that would be that your web server does not provide mod_rewrite. The difference is (as far as I can explain it) that errorhandling is part of the Apache web server while mod_rewrite is a module for Apache. (Of course, if you're on an nginx server, this explanation is moot.)

YL
jlr
Regular
Posts: 34
Joined: Sat Feb 18, 2012 12:50 pm
Contact:

Re: "RewriteEngine On" and static pages

Post by jlr »

yellowled wrote:The most likely explanation for that would be that your web server does not provide mod_rewrite. The difference is (as far as I can explain it) that errorhandling is part of the Apache web server while mod_rewrite is a module for Apache. (Of course, if you're on an nginx server, this explanation is moot.)
I think they claim they provide this module, but who knows ... however I'm rather sure it's an Apache server. Thanks for the explanation.
Post Reply