I'm working on trying to add new web site on subdomain but I'm getting Internal Server Error.
When I remove .htaccess from root folder subdomain site is working but current site brokes down.
.htaccess in root:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ app/ [L]
RewriteRule (.*) app/$1 [L]
</IfModule>
I'm trying to figure out how to setup .htaccess and make current site working and site on subdomain.
New website is in Drupal. Current web site is Cakephp
Update:
error_log
RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored
I fixed adding this in my root .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
RewriteRule ^$ app/webroot/ [L]
RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Related
I'm using some software that sits in the /var/www/html folder and manages URL redirects through .htaccess (the software isn't Wordpress, but it manages URL redirects in a similar way).
I need to carve two folders (/var/www/html/folder1 and /var/www/html/folder2) out from the redirect rules, which are at the very bottom of the .htaccess file. I read through a ton of documentation but can't seem to make the following work in .htaccess (which sits in /var/www/html):
Options -Indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
#force HTTPS
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#carve out these folders
RewriteRule ^/folder1($|/) - [L]
RewriteRule ^/folder2($|/) - [L]
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>
When I go to the directories in question (eg. https://example.com/folder1), I get: Forbidden You don't have permission to access /folder1/ on this server.
Any ideas?
I can't comment as I'm new but do the two folders have any sort of index page? Otherwise you will get a 403 response because you have disabled indexes at the top of your file excerpt.
When I attempt to hit my site which is at mydomain.com/subfolder, I get a 404 (from Apache).
/subfolder/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/subfolder/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
To confirm that mod_rewrite works, I added this in the /subfolder/.htaccess file which promptly redirected:
Redirect 301 / http://other-domain-owned.com/
So, .htaccess are live and mod_rewrite works.
On my development environment, I was able to make the site work in the same /subfolder by symply enabling .htaccess files for that folder via a Directory directive.
Some tutorials say to add RewriteBase / but this didn't help.
Instead of RewriteBase, you can also use an absolute path. Additionally, the first two rules can be simplified to one
RewritRule ^(.*)$ /subfolder/webroot/$1 [L]
Similar the second part
RewriteRule ^ /subfolder/webroot/index.php [L]
Finally, Redirect and RewriteRule are from different modules. So, if one of the directives is working, this is no proof for the other one working too.
I'm trying to add an addon domain with its own site to my hosting account which already has a cakephp setup.
I was experiencing a 500 error on the addon domain, but I managed to remove this using the solution at: http://expertsoverflow.com/questions/21345626/htaccess-addon-domain-issue-gives-500-error
Now my .htaccess file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^maindomain\.co.uk [NC]
RewriteRule ^(.*)$ app/webroot/$1 [L]
RewriteCond ^seconddomain\.report [NC]
RewriteRule (.*) http://seconddomain.report/$1 [L]
</IfModule>
Now my addon domain works as expected but my main domain isn't correctly forwarding image/file requests to the app/webroot folder so none of the images and css are loading and no pages work past the first index.
For reference the initial cakephp .htaccess file was:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Any help is appreciated.
Edit: my folder structure:
Main domain:
/public_html/
/public_html/app/webroot/
Second domain:
/public_html/seconddomain/
I managed to solve this by changing the directory of the addon domain.
Rather than having the addon domain in /public_html/seconddomain/ it is now /seconddomain/ in root. Then I'm just using the standard .htaccess files for cakephp in the /public_html/ folder.
I know it is very late but i got a solution for it.
Add the rewrite rule in primary .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} seconddomain.report
RewriteRule seconddomain.report/ - [L]
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I'm trying to set up CakePHP 2.x in Cpanel (Hostmonster) while the domain of the site is still pointing to the older server. In order to pull up the site without the domain (for demo), I have to use http://[hosting-IP-address]/~mysite.
This is my default .htaccess file located in the root (the one before app/ folder):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
If I leave it as it is, I get 404 error. When I remove the .htaccess file or leave it blank, the site content loads, but without CSS. The site files are located in /home2/mysite/public_html/ folder. I tried adding RewriteBase with different combinations (~mysite, mysite, mysite/public_html), but no avail.
Try this in htaccess file:-
<IfModule mod_rewrite.c>
RewriteBase /
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Hope it will work!
This is my .htaccess located at public_html
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I have a (legacy) CakePHP app running in public_html/app for maindomain.com
I added an addon domain otherdomain.com under public_html/otherdomain.
However, when trying to load the index page it returns a 500 server error.
Removing the public_html/.htaccess permits browsing otherdomain.com correctly, but the CakePHP app (maindomain.com) then has routing issues.
This is the CakePHP .htaccess under public_html/app:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
it appears that your main htaccess is redirecting traffic to your app/webroot/ which is causing problems for otherdomain.com.
Maybe you can check the hostname that is entered and redirect based on that.
Something like this.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^maindomain\.com [NC]
RewriteRule ^(.*)$ app/webroot/$1 [L]
RewriteCond %{HTTP_HOST} ^otherdomain\.com [NC]
RewriteRule (.*) http://otherdomain.com/$1 [L]
</IfModule>