I am rewriting sub-folders of my website to sub-domain via bellow code in Apache
vhost file:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www. example.com
RewriteCond %{HTTP_HOST} ^(www.)?(([^.]+).){1}example.com$
RewriteCond /var/www/example.com/web/crm/build/%3 -d
RewriteRule ^/(.*) /crm/build/%3/$1
so https://example.com/web/crm/folder
= https://folder
.example.com
Also i am using .htaccess
to hide /index.php/ in codeigniter
url
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
AddDefaultCharset utf-8
example.com/web/crm/folder
works fine
folder.example.com
i get 505 internal error which gets fine once i delete lines in .htaccess or just simple access website via folder.example.com/index.php/ (Nothing is showing up in log)
I want to fix rewrite conflict for sub domain
2
Answers
Fixed
OK, two suggestions:
It would be nice to know what specific server-side error is causing the HTTP 505.
Please copy/past the exact message from your server log into your post.
It would also be nice to know exactly how your rewrite rules are being interpreted.
Please enable logging as follows:
George Samarguliani added this comment, which explains the HTTP 505 error:
I copied/pasted the vhost snippet above into the first handy Apache config validator, https://htaccess.madewithlove.be/, and got this:
So now at least we know what’s causing the server-side error: Apache vhost configuration.
NEW SUGGESTIONS:
As far as the “index.php”, I don’t even think you need or want a re-write rule.
Just configure “DirectoryIndex”, like this:
As far as the rest of the URL (e.g. “http://example.com/web/crm/build/`), please update your post with before/after examples of how you would like to the redirect to actually work.
There are lots of good “howtos”, with good examples, for using .httaccess/mod_rewrite rules. For example: