• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

mod_rewrite Problems...

zeroborg

Basic Pleskian
Hi all...

I can't make mod_rewrite to work.
I add the vhost.conf to /srv/www/vhosts/domain.com/conf with the following data:
===================
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /km/index.php?page=$1 [L]
===================

I run /usr/local/psa/admin/sbin/websrvmng -v -a

And when i try to see the result to page:
http://www.domain.com/km/index.php?page=1000
(which has to be retyped to: http://www.domain.com/1000.html )
nothing happens...
The rewrite works on the background. When i examined the logs of the rewrite engine i found that it PASSES THROUGH anything...
==================
(2) init rewrite engine with requested uri /km/index.php
(3) applying pattern '^([^/]*)\.html$' to uri '/km/index.php'
(1) pass through /km/index.php
==================

Does anyone knows why? Please advise.
Thank you.

Zeroborg.
 
I am confused.

Are you trying to rewrite the pattern *.html to /km/index.php?page=$1 or are you trying to rewrite the pattern /km/index.php?page=* to $1.html?

Your rewrite rule will match something.html and rewrite it to /km/index.php?page=something

Is that what you are trying to accomplish?
 
you should try it in...

.htaccess of the httpdocs.. I have managed to get it working on mine.

you don't need the Symlink part..
 
Alright, we are now on the same page.

You can do this in a couple of ways, but probably the easiest is going to be to create an .htaccess file in the root of the site.

Obviously you have mod_rewrite working.

Here is a sample of what I have been using for a similar rewrite situation. I will explain each line in a little more detail to help you understand what is going on.

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ /km/index.php?page=$1 [L]

Here is what each line does:

RewriteEngine On

This turns on the rewrite engine

RewriteCond %{REQUEST_FILENAME} !-f

This line checks to make sure the requested file does not exist. This is handy to prevent requests for legitimate files from being passed through to the mod_rewrite rule that follows.

RewriteRule ^(.*)\..html$ /km/index.php?page=$1 [L]

This looks for anything ending in .html and passes the pattern before that to /km/index.php?page= in the value of $1.

A word of caution: this rule is "greedy" meaning it can match A LOT of patterns you might not want it to match. Make sure you test it and that it behaves how you expect it to. This will also match requests for files in subdirectories too (/foo/bar/something.html) and will pass that entire string to your page variable.

Good luck.
 
Back
Top