0

Testing two identical folders , one placed in a Drupal install folder and the other in a plain html subfolder in home root , only the php links for the one in CMS install work. This makes sense because Drupal has a settings php file and .htaccess file which makes sure everything is in its proper place for links to work whether in home root or not. However I thought it would be easy enough to get the links to work in plain html subfolder with a simple rewrite rule in the .htaccess file which exists in the php folder. Yet try as I might, nothing has worked so far.

The configuration in /etc/httpd/conf.d/my.conf

<VirtualHost *:80>
ServerName drupalsite.com
ServerAlias www.drupalsite.com
ServerAdmin vps@drupalsite.com
DocumentRoot "/var/www/html/drupalsite.com"
<Directory /var/www/html/drupalsite.com>
AllowOverride All
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName plainhtml.com
ServerAlias www.plainhtml.com
ServerAdmin vps@plainhtml.com
VirtualDocumentRoot "/var/www/html/plain”
</VirtualHost>

The .htaccess file in identical php folders

RewriteEngine On
RewriteBase /phpfolder/

RewriteRule ^c-(.*)$ catpost.php?id=$1 [L]
RewriteRule ^a-(.*)-(.*)$ archives.php?month=$1&year=$2 [L]

RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*)$ viewpost.php?id=$1 [QSA,L]

So drupalsite.com/phpfolder links all work

But plainhtml.com/phpfolder links do not work

phpfolder for Drupal resides in /var/www/html and Drupal site is symlinked

phpfolder for plain html subfolder to root resides in /var/www/html/plain

Both phpfolders are owned by apache:root and all files within are owned by root:root

Have also tried changing the .htaccess rewrite rule to:

RewriteBase /

RewriteBase /plain/

RewriteBase /plain/phpfolder/

cea
  • 285
  • 3
  • 11

1 Answers1

0

You will have to define a Directory entry with AllowOverride for: /var/www/html/plain

<Directory /var/www/html/plain>
    AllowOverrideAll
    Allow from all
</Directory>

Note: If you have access to the main configuration file of the server you shouldn't be using .htaccess, configuring Rewrites or Redirects in Virtualhost is simpler. As you have already seen, using sub-files and per-dir configurations make things more complicated, not counting the overhead of apache having to constantly check those files when AllowOverride is enabled.

Daniel Ferradal
  • 2,727
  • 1
  • 13
  • 19
  • actually it is quite complicated because the configuration file is set to listen to the .htaccess file and is set commented out to Directory, Allow from all . This is because the Drupal side of things is a multi-site set up with symlinks to /var/www/html ...so it seems impossible to get both sides to work now and I am still completely stuck. I'm sorry but the above won't work, it actually renders link completely dead not even 404. – cea Apr 28 '17 at 12:41
  • I solved it finally with changing the configuration to /var/www/html/plain/phpfolder and the .htaccess file in phpfolder to RewriteBase / – cea Apr 30 '17 at 02:04