I have an .htaccess file with this
Options FollowSymLinks
RewriteEngine on
#RewriteCond $1 !^(index\.php|images|assets|layout|avatars|custom|js|media|script|skin|uploads|isAjax|robots\.txt)
# To be deployed on LIVE only
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301]
# Everything else to the CI controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
But when I open my site, Show me :
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Thanks all for your Help.. :)
Related
I have an app that works on my local machine using MAMP, but fails to redirect to a certain page on the live server. I have narrowed this down to the .htaccess file but can't seem to get the exact configuration. It happens when I sign up a user on my Codeigniter-based app and it's supposed to redirect to another page, but doesn't.
This is what I have currently,
RewriteEngine on
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://website.com/$1 [R,L]
# Hide all PHP files so none can be accessed by HTTP
RewriteRule (.*)\.php$ index.php?/$1
# If the file/dir is NOT real go to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
Try to used like this
I have created sub-domain like this in Codeigniter 3
www.test.example.com
I have used this .htaccess and it's working only home page.
www.test.exapmle.com for other pages like www.test.exapmle.com/page1 or www.test.exapmle.com/page2
.htaccess I used:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public_html/index.php/$1 [L,QSA]
I am getting this error:
the server encountered an internal error or misconfiguration and was
unable to complete your request.
In .htaccess file just insert the following code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
So, I recently installed codeigniter in a subdomain and I'm getting 500 error when I try to access it. Script should run normal, I had it on several other domains and my guess it's htaccess on the main domain folder (public_html).
Here's the .htaccess from the "root" folder
#OLD
RewriteCond %{HTTP_HOST} ^domain.tv$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.tv$
RewriteCond %{HTTP_HOST} !^db\.domain\.com$ [NC]
RewriteRule ^/?$ http://domain.com/blog/topics/vidcast/ [R=301,L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^blog/index.php/archives/category/podcast/feed$ http://feeds.feedburner.com/domainPodcast [R=301,L]
#RewriteCond %{HTTP_HOST} !^(www|ftp|webmail)\.milaraki\.com
#RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com
#RewriteRule (.*) http://domain.com/blog/wp-content/uploads/%1/$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
And here's the .htaccess in the subdomain (named: db.domain.com)
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-z0-9_-]+)\.html$ index.php/page/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|asset|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Now, whenever I try to access "http://db.domain.com", it redirects me to "http://db.domain.com/blog/". If I try to access by subfolder
like "http://domain.com/db" it give's me an 500Error.
We also get these spam of lines in apache/error_log:
warn] (103)Software caused connection abort: mod_fcgid: ap_pass_brigade failed in handle_request function
Also, let me tell you it's in a VPS and the "root" .htaccess file it's not made by me, but from the client, all I have done, it's to add an extra line in his .htaccess file to "stop" the redirect but it's not working at all.
That's the line I added (already in the code i posted)
RewriteCond %{HTTP_HOST} !^db.domain.com$ [NC]
It still gives the error even if I remove it or leave it there.
Oh and, in the "root" folder, he installed WordPress.
Hope I was clear enough, feel free to ask me other questions.
So, I ended up removing the lines bellow from the .htaccess file inside the "root" folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Restarted Apache (no idea why this is necessary) and the new settings fixed everything...
I have this project which is from a remote server.
Then I FTP everything to my local machine which is localhost, then when I type the URL, for example, localhot/test it redirects to the production site.
I want that when I type into my localhost not to be redirected to the production site. I think this is somewhere in .htaccess, can someone help me this one?
This is my .htaccess code:
# see if the module is active
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
RewriteCond %{HTTP_HOST} ^\*\.test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.\*\.test\.com$
RewriteRule ^/?$ "http\:\/\/test\.com" [R=301,L]
RewriteCond %{HTTP_HOST} ^jobs\.test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.jobs\.test\.com$
RewriteRule ^/?$ "http\:\/\/test\.com" [R=301,L]
Anyway, the project is written in CodeIgniter framework.
Any help is much appreciated.
Firstly I implemented a rewrite rule for my REST API on an apache2 server with the following .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ index.php [QSA,NC,L]
</IfModule>
It worked fine. If I entered e.g. http://mypage.de/REST/SomeRule/12 my index.php in the folder REST/ received the information SomeRule/12.
Now I enabled SSL on my server and I wanted to force the API to use https so I added the following code to my .htaccess file:
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
Now I receive a page not found error. Can you see the error in the .htaccess file, or must it be somewhere else? I am not that familiar with these files. To create my API I used this tutorial.
With the help of anubhava I found the solution.
When I updated my server to run with https my folder sites-enabled included a new file sites-enabled/default-ssl. In this file I had to set
AllowOverride All
like I already did for the on using http. I addition the correct solution for the .htaccess file was the following:
<IfModule mod_rewrite.c>
RewriteEngine On
#use https
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/%{REQUEST_URI} [L]
#used for api
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ index.php [QSA,NC,L]
</IfModule>
I was not able to use
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L]
because the $1 then was somehow overwritten for the next Rule.