Setting up friendly URL in production mode

I am experiencing a Plone url rewrite problem with my Virtual Hosting setup: Debian, Apache2 and a Plesk web admin setup. I have a website which I’d like to re-direct to my plone instance

Following the advice of
I put the Plone rewrite rule on a file that can cause the rewrite to happen. The file is:

I had made sure the mod_rewrite is on and works. I knew that because I had tested it with the following rule:

RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^ [OR] RewriteCond %{HTTP_HOST} ^ RewriteRule ^(.*)

Running the above rule simply jumps the url to the destination url.

But when I paste in

RewriteEngine On
RewriteRule ^/(.*)$1 [L,P]

The rule did not work.

I have tried putting the rewrite rule in other Apache2 configure structure such as: /etc/apache2/sites-enabled/

As suggested on the plone documentation

" ... Add virtual host config file /etc/apache2/sites-enabled/yoursite.conf. Assuming Plone is your site id in Zope Management Interface (capital lettering do matter) and your domain name is ...."

to no avail.

I have previously run my plone production on CentOS/Plesk/Apache the plone rewrite rule worked with no problem. Has anyone seen the same problem?

Is the site ID "openbean" misspelled?

...and yeah I would refer to the official docs first. The Stack Overflow question you referred to first was from 2009.

Kim, it's misspelled when I created my forum post. It is correctly spelled openbeam on the .htaccess file

I've never seen anyone use the .htaccess file that way. A more typical file in which to put rewrite rules for Apache would be called /etc/apache2/sites-enabled/ but it will depend on your system.

I have put the plone rewrite code /etc/apache2/sites-enabled/ there as well. It didn't work.

In fact, even when I put the following code :

UseCanonicalName On

NameVirtualHost *
<VirtualHost *>
ServerSignature On

Header set X-Frame-Options "SAMEORIGIN"
Header set Strict-Transport-Security "max-age=15768000; includeSubDomains"
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options "nosniff"
Header set Content-Security-Policy-Report-Only "default-src 'self'; img-src *; style-src 'unsafe-inline'; script-src 'unsafe-inline' 'unsafe-eval'"

ProxyVia On

# prevent your web server from being used as global HTTP proxy
<LocationMatch "^[^/]">
  Deny from all

<Proxy *>
    Order deny,allow
    Allow from all
# The following code works if I put in /var/www/vhosts/          
RewriteEngine On
RewriteCond %{HTTP_HOST} ^ [OR]
RewriteCond %{HTTP_HOST} ^ 

RewriteRule ^(.*) 

<VirtualHost *>
ServerAlias *
ServerRoot /var/www
ServerSignature On

RewriteEngine On

RewriteBase /
RewriteCond %{HTTP_HOST} ^ [OR]
RewriteCond %{HTTP_HOST} ^ 

RewriteRule ^(.*) 

worked in /var/www/vhosts/

The rewrite does not take place. It's as if my set up is such that rewrite works only in var/www/vhosts/

It would help to see the Apache log messages to understand why it's not working. Also would help to see your Apache configuration file.

What I stumbled upon is that for unknown reason, my Apache2 config is such that
the RewriteRule ^/(.) pattern does not fire the rewrite . When I replaced it with ^(.) ie, the "/" has been elimiated then the pattern will trigger.

What I have now in the .htaccess file is
RewriteRule ^(.*) http://localhost:8084/VirtualHostBase/http/%{HTTP_HOST}:80/openbeam/VirtualHostRoot/$1 [P,L]

By doing that a url like: and get properly redirected without explosing the long url. However, the rewrite pattern is such that and its Home tab is not referencing the right place. I need to figure out a rewrite rule for the case when there is no child.

And also I have absolutely no idea why my Rewrite engine works differently.

Maybe you could paste here your complete Apache configuration?

It turns out for my Plesk, Debian, Apache2 configuration, I had to put my rewrite rule in
/var/www/vhosts/system/xxx/conf/httpd.conf file. This file was initially generated by Plesk admin console when I add a doman or subdomain via Plesk. /etc/apache2/sites-enabled/xxx.conf has no effect on my system. I cannot explain why. All I know is that it works.

1 Like