RewriteBase in Drupal not working - .htaccess

I just developed Drupal based website, instead of old one "custom" made.
Problem I'm facing is that root of website is not apache root. It is in directory:
/public_html/mydomain/htdocs/
Due to all of that, my links now looks like:
http://www.mydomain.com/mydomain/htdocs/php
http://www.mydomain.com/mydomain/htdocs/java
http://www.mydomain.com/mydomain/htdocs/jquery
Tried to change directive in Drupal's .htaccess file, with:
RewriteBase /mysite/htdocs
... but that made no changes to links.
Also, with previous website all links worked fine...
Can you tell me how to fix this directive.
Thank you in advance!

RewriteBase is not used for that purpose. You need to be editing the virtual host or vhost file. Find the vhost file in your apache configuration and change the DocumentRoot to your folder /public_html/mydmian/htdocs/ and just comment-out rewritebase.
RewriteBase is if your site is in a sub-folder of a "document root." What you have IS the document root.

Related

500 Internal Server Error for sub domain using htaccess in SilverStripe 3.1

I am getting a 500 server error for a sub domain. It was working perfectly before installing SilverStripe 3. Is there any modification needed in the default .htaccess created by SilverStripe installation?
This answer makes a few assumptions from your question.
These assumptions are
Your SilverStripe website is the root website (e.g. http://www.example.com)
Your SilverStripe code is in the root web directory (e.g. /public_html)
You sub-domain code is in a sub-folder of the root web directory (e.g. /public_html/sub
The problem that can occur in the above situation is the sub-domain may use the /public_html/.htaccess file and use its mod_rewrite rules.
To solve this we can create a .htaccess file in the sub-domain (/public_html/sub/.htaccess) with the following code:
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase /
</IfModule>
This will tell the server to not use the mod_rewrite rules or base of the root .htaccess file.
An alternative solution could be to not place sub-domain code in a sub-folder of the root web directory. You can create a folder on the root level such as /sub and have your sub-domain point to there.
Thanks every one for their support, but I follow different method.
I have created sub domain from cpanel, but selected same root folder instead of creating new directory.
I got the help from here.
https://forums.cpanel.net/threads/domain-redirecting-to-cgi-sys-defaultwebpage-cgi.139597/page-3#post-656642

.htaccess file 404 error with parallel plesk server

I have my .htaccess file working in localhost. But its not working if i upload it in server. It throws me 404 error.
I am using Parallel Plesk 11.0.9 and i can't find conf file for the same on that. If anyone has any idea how to fix it or any workaround for url rewriting would be great help.
Anyway here's the code in htaccess:
RewriteEngine on
RewriteRule ^store/living/Hutches-Armoires-Side-tables-Coffee-tables-Entertainment-centers? store.php?store=Living
RewriteRule ^store/dining/sideboards-buffets-chairs-benches-Dining-table$ store.php?store=Dining
RewriteRule ^store/working/Bookshelves-Study-tables$ store.php?store=Working
RewriteRule ^store/accessories/Boxes-Photo-Frames-Mirror-Frames-Block-Stamps-and-Book-stands$ store.php?store=Accessories
RewriteRule ^store/hallway/Console-tables-Armoires$ store.php?store=Hallway
RewriteRule ^store/sleeping/Bed-Frames-Night-Stands-Dressers-Mirror-framesBed-Linens-Canopies-Curtains$ store.php?store=Sleeping
You may need to wrap your rewrite rules with:
<IfModule mod_rewrite.c>
...
</IfModule>
...probably a good idea anyway.
Or you could try putting your rules into a vhost.conf file in the conf directory immediately below the location of your httpdocs directory. For example on a Centos machine the web root might be
/var/www/vhosts/domain.com/httpdocs
and you should have a:
/var/www/vhosts/domain.com/conf
directory, this will contain a set of pregenerated Apache config files that Plesk creates. If there isn't already create a vhost.conf and add your rules between a set of
<Directory /var/www/vhosts/domain.com/httpdocs/ >
... your rules ...
</Directory>
Once you've created the vhost.conf file you will need to tell plesk about it with
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain domain.com
If you still can't get it to work you can add a log for mod_rewrite, see this relevant SO answer for details
Is your Plesk running IIS and supporting PHP via FastCGI or ISAPI? If that is the case, check whether URL Rewrite is installed and follow this guide to translate htaccess (for apache) into web.config (for IIS)

Need to show static directory located in root of WP install

I'm trying to navigate to a directory (/mobileapp/) containing a static mobile web app, located in the root of my WP install.
My problem is that when I try going to the url (http://dawsondental.ca/mobileapp/ <--the live site if you want to check it out) I get the usual WP 404 Not Found page.
I tried creating an .htaccess file within the /mobileapp/ directory with the following:
<IfModule mod_rewrite.c>
#Disable rewriting
RewriteEngine Off
</IfModule>
But it's still not working. Maybe the WP permalink rewrite conditions are still taking over? Any ideas?
Move the WordPress/MobileApp directory out of WordPress to your Web Root folder (say, /public_html or /www). Then try accessing it as http://dawsondental.ca/mobileapp/.

.htaccess not working on localhost with XAMPP

i m using XAMPP but i m not able to use .htaccess file at local host. i m trying so many times.. Online working good. but local host showing [The requested URL was not found on this server]
My root folder is real
localhost/acre/real/property_available.php
localhost/acre/real/properties
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /acre/real/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^properties$ /property_available.php/$1 [NC,QSA]
</IfModule>
Please
Just had a similar issue
Resolved it by checking in httpd.conf
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All <--- make sure this is not set to "None"
It is worth bearing in mind I tried (from Mark's answer) the "put garbage in the .htaccess" which did give a server error - but even though it was being read, it wasn't being acted on due to no overrides allowed.
In conf/extra/httpd-vhosts.conf, add the line AllowOverride All for all the websites that you are having problem with
<VirtualHost example.site:80>
# rest of the stuff
<Directory "c:\Projects\example.site">
Require all granted
AllowOverride All <-----This line is required
</Directory>
</VirtualHost>
Try
<IfModule mod_rewrite.so>
...
...
...
</IfModule>
instead of <IfModule mod_rewrite.c>
Without seeing your system it's hard to tell what's wrong but try the following (comment answer if these didn't work WITH log error messages)
[STOP your Apache server instance. Ensure it's not running!]
1) move apache server/install to a folder that has no long file names and spaces
2) check httpd.conf in install\conf folder and look for AccessFileName. If it's .htaccess change it to a file name windows accepts (e.g. conf.htaccess)
3) double-check that your htaccess file gets read: add some uninterpretable garbage to it and start server: you should get an Error 500. If you don't, file is not getting read, re-visit httpd.conf file (if that looks OK, check if this is the only file which defines htaccess and it's location and it does at one place -within the file- only; also check if both httpd.conf and htaccess files are accessible: not encrypted, file access rights are not limited, drive/path available -and no long folder path and file names-)STOP Apache again, then go on:
4) If you have IIS too on your system, stop it (uninstall it too if you can) from services.msc
5) Add the following to the top of your valid htaccess file:
RewriteEngine On
RewriteLog "/path/logs/rewrite.log" #make sure path is there!
RewriteLogLevel 9
6) Empty your [apache]\logs folder (if you use another folder, then that one :)
7) Check the following entries are set and correct:
Action application/x-httpd-php "c:/your-php5-path/php-cgi.exe"
LoadModule php5_module "c:/your-php5-path/php5apache2.dll"
LoadModule rewrite_module modules/mod_rewrite.so
Avoid long path names and spaces in folder names for phpX install too!
8) START apache server
You can do all the steps above or go one-by-one, your call. But at the end of the day make sure you tried everything above!
If system still blows up and you can't fix it, copy&paste error message(s) from log folder for further assistance
I had a similar problem. But the problem was in the file name '.htaccess', because the Windows doesn't let the file's name begin with a ".", the solution was rename the file with a CMD command. "rename c:\xampp\htdocs\htaccess.txt .htaccess"
for xampp vm on MacOS capitan, high sierra, MacOS Mojave (10.12+), you can follow these
1. mount /opt/lampp
2. explore the folder
3. open terminal from the folder
4. cd to `htdocs`>yourapp (ex: techaz.co)
5. vim .htaccess
6. paste your .htaccess content (that is suggested on options-permalink.php)
For windows user, make sure to closely look at this section.
RewriteRule ^properties$ /property_available.php/$1 [NC,QSA]
As said in Apache documentation :
The mod_rewrite module uses a rule-based rewriting engine, based on a
PCRE regular-expression parser, to rewrite requested URLs on the fly.
So ^properties$ means Apache will only look for URL that has exact match with properties.
You might want to try this code.
RewriteRule properties /property_available.php/$1 [NC,QSA]
So Apache will see the URL that has properties and rewrite it to /property_available.php/
I've setup xampp for my localhost as well, I've not done anything with the files created by xampp during or after setup.
But in the '.htaccess' file, make sure you've set it to something like this. Works for me, and this should not make any difference for you.
RewriteEngine On
RewriteRule ^filename/?$ filename.html
Change .html to whatever format you're using.
Make sure your install is clean, and just make the .htaccess file.
Also remember to put one .htaccess file for each directory (don't really know if you can use ONE file for all folders, but to be safe, just do this and it will always work.
Edit the .htaccess file, so the first line reads 'Test.':
Test.
Set the default handler
DirectoryIndex index.php index.html index.htm
...

index.cfm append with SES URL in MURA

Recently working with MURA CMS with RAILO on UBUNTU. I am installing MURA in inner folder of root directory.
public_html >> website.
Following code added in .htaccess to rewrite URL to run website without index.cfm and website directory.
Options +FollowSymLinks
RewriteEngine On
DirectoryIndex index.cfm
RewriteRule ^$ /website/ [R]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^website/([a-zA-Z0-9/-\s]+)$ /website/index.cfm/$1 [PT]
So my url http://example.com/website/privacy/ rewrite as
http://example.com/website/index.cfm/privacy/
I think rewrite rule should work correctly as I have tried some online validator and giving me correct result but if run it into MURA it produce URL like
http://example.com/website/index.cfm/privacy/index.cfm
I am not sure who is adding last index.cfm (apache or mura) and this take me to 404 page everytime.
Please help... this driving me crazy..
Thanks,
Pritesh
UPDATE
I have same site setup with windows/IIS 7 under subfolder of root and work fine though, if that help
To take off index.cfm of the URL, you have to edit file settings.ini.cfm
To edit this file
go to Modules / File manager
Then tab Application Root
Select folder config
Then right click on settings.ini.cfm and edit
In this file, siteidinurls and indexfileinurls have to be at 0
siteidinurls=0
indexfileinurls=0
After change, you have to reload application by clicking on Reload application on the Settings menu at the top of the window.
Thanks Matt and Mael for spending time for this issue.
Finally figure it out that TOMCAT was causing issue and adding index.cfm at the end.
<url-pattern>/website/index.cfm/*</url-pattern>
Add above URL pattern in web.xml file and it start working fine.

Resources