I have a domain say abcdefgh.com hosted on Hostgator Cpanel VPS Server. It has a folder inside public_html/abcdefgh.com.
Below are the images of deploying my yii2 website but I am unable to get the result on website.
I had previously deployed the Yii2 applications on shared hosting the same way copy pasting the folder, but here in VPS server, I am curious to know what is wrong in this?
1. Hostgator Cpanel VPS Server Deployment
2. Output
3. Server Error Log
Mon Apr 17 22:48:01.706049 2017] [autoindex:error] [pid 32221] [client 117.208.9.75:49825] AH01276:
Cannot serve directory /home/abc/public_html/abcdefgh.com/: No matching DirectoryIndex
(index.php,index.php5,index.php4,index.php3,index.perl,index.pl,index.plx,index.ppl,index.cgi,index.jsp,index.js,index.jp,index.phtml,index.shtml,index.xhtml,index.html,index.htm,index.wml,Default.html,Default.htm,default.html,default.htm,home.html,home.htm) found, and server-generated directory index forbidden by Options directive
.htaccess file
Options -Indexes
# Rewrite engine
RewriteEngine On
# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
Delete this from the .htaccess file:
Options -Indexes
Save file and try again!
Related
I've developed a tiny app in a hosted server via cPanel, by using node js with express and mysql.
so when the app is running via node or forever, it is accessible only when I add the port number in the url. but when the url is without the port, it goes to an Index of the files in the folder of the subdomain. and everyone can view the app.js file including the password to mysql and user name etc...
I thought js files are not accessible or viewable to the client??
what am i doing wrong?
Create ".htaccess" file in the root of your project with following content
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXX/$1 [P,L]
Where the "XXXX" is the port, that you're using.
I'm new to laravel. It's really good application. I developed web application using laravel docs. But the problem is how to deploy it on live server.
In local development environment we use "php artisan serve" command and can access project from http://localhost:8000.
But what should be proper way to run it on live domain. Please don't suggest me something like copy htaccess to root directory and rename server.php to index.php etc.
I will suggest you to watch video from Youtube videos : Move Laravel to Live
This video help you to install to server ; after installing you may even just ise composer or by copying files to server you can run your project in your live server.
Just be sure you installed laravel .
Of problem exists please let me know.
This .htaccess file will point to public/index.php file
DirectoryIndex public/index.php <IfModule mod_rewrite.c><IfModule mod_negotiation.c>Options -MultiViews</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]</IfModule>
I have a site I'm making with purely static html pages and I'd like to not have the .html extension on the webpages. I've read dozens of links with different ways to edit the .htaccess file to rewrite urls without the extension, but with no luck.
The strange thing is, I had the .htaccess file on my other site (bradleyoesch.com) and I can access pages without .html at the end (e.g. bradleyoesch.com/projects). However, I deleted the .htaccess file on that site and it still works (bradleyoesch.com currently has no .htaccess file), suggesting to me that I did something else two years ago to get it to work, or I need to restart something to pick up the changes (I've restarted apache on both servers with sudo service apache2 restart).
What am I missing or forgetting to do, or otherwise why would my .htaccess changes not work? My current .htaccess file contents are below.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
Ok here's what finally worked. There were some edits to apache2 files I needed to do to get everything to work together. This assumes you're running apache2 version 2+ on your server with some form of linux.
Edit /etc/apache2/sites-available/000-default.conf to have the following lines, just append them to the end (I put them after this line: # vim: syntax=apache ts=4 sw=4 sts=4 sr noet).
<Directory /var/www>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Create or edit the .htaccess file in your root html directory (mine is /var/www/html and note the similar directory path above) with the following lines:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
When you make any changes to an apache2 conf file, you have to restart apache2, and if you have not yet, you want to create some symlinks with a2enmod. Otherwise just restart apache2.
sudo a2enmod rewrite && sudo service apache2 restart
You do not need to restart anything when making changes to .htaccess. An easy way to check if it's loading .htaccess at all is to type gibberish in there to force a syntax error, then your pages will 500 error.
With rewrite rules you can use MultiViews to allow Apache to load pages with .html or .php extensions. Just use this line in your Apache config or site root .htaccess:
Options +MultiViews
I know there are more questions and answers about that but none of them was usefull to me.
I just configured my website on a apache linux server,that I'm managing with cPannel.And I edited my .htaccess file to remove html extensions from my url. But after I uploaded it to File manager , nothing changes.What do I need to do to make it work ?
I've been searching for configuration files to set AllowOverride All but I didn't found anything.And also I don't have etc/apache2/ directory in my file manager, there are other files in etc/ directory.
EDIT: Server info :
Hosting Package:Startup2013
Server Name: wolf
cPanel Version: 11.50.1 (build 3)
Theme: paper_lantern
Apache Version: 2.4.16
PHP Version: 5.6.12
MySQL Version: 5.6.23
Architecture: x86_64
Operating System: linux
Shared IP Address: 185.81.0.40
Path to Sendmail: /usr/sbin/sendmail
Path to Perl: /usr/bin/perl
Perl Version: 5.10.1
Kernel Version: 2.6.32-573.3.1.el6.x86_64
Here is my .htaccess code :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
I assume that you're not running an ubuntu server, that's why you don't have /etc/apache2 directory.
Try this:
Edit the httpd.conf file in /etc/httpd/conf/httpd.conf and set the AllowOverride All
then: apachectl restart
If this doesn't work please run: cat /etc/*-release and show us the output, so we can know which linux distribution you are running.
EDIT: .htaccess was working fine, OP wanted to remove .html extensions
This is the .htaccess you need in order to remove .html extensions:
RewriteEngine On
RewriteBase /
#Removes .html extension
RewriteCond %{THE_REQUEST} ^[A-Z]+\s.+\.html\sHTTP/.+
RewriteRule ^(.+)\.html $1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
I'm very new to web development, and know nothing of back-end dev. I have a website hosted by a 3rd party on a Linux server, using cPanel.
I have a index.html page that is loaded when you go to the website www.domain.com and I have a second file page2.html that loads when I go to www.domain.com/page2.html
Problem 1:
I want to be able to go to www.domain.com/page2 and have page2.html load.
Problem 2:
When I go to www.domain.com/page3.html (which doesn't exist) or www.domain.com/page3 or any other non-existent url index.html loads instead of giving me a 404 error. I have made a custom 404 page (404.shtml) which is in the same directory as index.html and page2.html (/public_html/).
How do I get this 404 page to show when I go to a non-existent URL? I checked the error log on cPanel and it shows a File does not exist error.
[Fri Aug 29 20:16:48 2014] [error] [client ...*] File does not exist: /home/adminName/public_html/page3, referer: http://domain.com/page3/
Any pointers in the right direction would be very helpful.
To remove the suffix (.html) from your url, you would need to use .htaccess.
The following will first check if the request is a file (images/css etc.) or directory, then serve the file without the suffix.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]
The following will serve a custom 404 error document
ErrorDocument 404 /404.shtml
I just found a similar StackOverflow Question for Problem 1, and the second answer, by Ćukasz Habrzyk, worked for me.
#example.com/page will display the contents of example.com/page.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
#301 from example.com/page.html to example.com/page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]