Actually my website works in localhost, why do I get Internal Server Error in live?
I have attached my .htaccess file here, are there any errors in it?
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
# Make backend accessible via url:
RewriteRule ^sysadmin& backend.php
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule ^.*$ /index.php [L]
Just try to add the following rule in your htaccess:
RewriteBase /
You should check your apache log. I had same problem, and I checked error log. There was an error that invalid command "RewriteEngine" It means rewrite module is disabled. You must enable it. For linux:
Under Apache 2+ you can simply do:
sudo a2enmod rewrite && sudo service apache2 restart
or
sudo a2enmod rewrite && sudo /etc/init.d/apache2 restart
Related
I have been trying to shorten URLs with apache .htaccess file, and currently I have this code:
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^(.*)$ show.php?page=$1 [NC, QSA, L]
AllowOverride All
With this code, for example https://example.com/welcome should be redirected to https://example.com/show.php?page=welcome, but it is not. When I run sudo a2enmod rewrite, I get the following:
Module rewrite already enabled
I also tried to run service apache2 restart. How can I solve it?
I am facing one issue related to the angular app, using components in my app then when I go with the single page the page loaded successfully but when I open that URL in a new tab or reload it, give error Not found.
I am using AWS apache server for this and only facing this issue on it, in my Godaddy server page reloading working properly.
Here I am attaching my screenshot of the error.[
Thankx in advance
I think your .htaccess file is not reachable,
Create .htaccess file inside /var/www/html i.e. in the folder where your index.html is.
Put following code in it:-
RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html
Than goto /etc/apache2 folder and open apache2.conf file with sudo.
cd /etc/apache2
sudo vim apache2.conf
Remove comment(#) of AccessFileName it will look like
AccessFileName .htaccess
Then find the line where there is
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
replace "None" with "All"
AllowOverride All
Done!
Now run command
sudo service apache2 restart
And check now!
Add .htaccess file in your project root folder.
bellow code add in your Appache .htaccess file:
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
Nginx .conf file :
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.html break;
}
}
execute command :
sudo a2enmod rewrite
sudo service apache2 restart
I am able to deploy react app on apache server, to login and the home page displays. All links work properly.
The problem occurs when I refresh the page (using F5). It says:
The requested URL /home was not found on this server.
I did almost everything like RewriteEngine set to On in .htaccess file.
RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html [L]
Am I missing something?
You .htaccess seems okay, but it might be ignored by Apache.
You should
Check if AllowOverride is set to All for the Directory you're serving the website from (in your Apache vhost configuration file, under /etc/apache2/sites-enabled)
Check if the rewrite mod is enabled (enable it with sudo a2enmod rewrite, then restart Apache with sudo systemctl restart apache2)
I've made a website in PHP, tested it locally and it works fine. Now I pushed it to my actual webserver and now I'm having trouble, because my .htaccess - file should redirect all calls, but it's getting ignored.
This is my .htaccess - file
AddDefaultCharset UTF-8
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
RewriteRule ^(controllers/|core/|models/|views/) - [F,L,NC]
</IfModule>
I've already searched for a solution and came up with running these commands:
a2enmod rewrite
a2enmod expires
a2ensite default-ssl
After each command i restarted the server.
The last command in the list above gives me an error:
apache2: Syntax error on line 224 of /etc/apache2/apache2.conf: Syntax error on line 166 of /etc/apache2/sites-enabled/default-ssl.conf: Expected </VirtualHost> but saw </IfModule>
Action 'configtest' failed.
Does someone have a solution for this?
Look in your /etc/apache2/sites-enabled/default-ssl.conf file. Does it have one <VirtualHost> opening entry without the corresponding </VirtualHost> closing entry?
I have frusted doing all things given on web for htaccess get working on ubuntu. But I could not do it. Actually I want to run my CodeIgniter app on LAMP, its not production server. so in www directory, there could be multiple folders e.g.
www/punepchub
I access url localhost/punepchub/support/ , it gives 404 error
I want to redirect above link to localhost/punepchub/index.php/support/
using htaccess, following are the contents of htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Where as above mentioned htaccess works perfect on wamp as well as lamp given by godaddy hosting, but it is not working on LAMP server setup on my local ubuntu 12.04 desktop machine
I think apache is not accessing the htaccess file.
I tried following but It didn't worked
I have installed lamp using tasksel
Enabled Rewrite module using command: sudo a2enmod rewrite
It displays the module in the list given by command: sudo apache2ctl -M
Changed etc/apache2/sites-available/default file with AllowOverride All, Also I did same in etc/apache2/sites-enabled/000-default
I have 777 permissions for project folder and files
Also I am confused about Is there any need to create virtual hosts, as this is not production server.
Please help me I really don't know how resolve this issue now.
In advance many thanks
Try this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /punepchub/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /punepchub/index.php [L]
</IfModule>