I imported a wordpress production website into my local server to modify it and learn how to wordpress. I use LAMP and my WordPress project is located on a different Hard Drive than my Ubuntu 16.04 partition. But even if I can access to the main page, all the other links (except /wp-admin) are returning a 404 not found error.
As I could read, the problem could be that the .htaccess file was not read by apache2. To enable this option, I needed to enable the plugin rewrite with sudo a2enmode rewrite and to change in /etc/apache2/sites-enabled/000-default.conf the :
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
</Directory>
by :
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
If this may correct the error 404, it creates an internal server error...
Is anyone have an idea of how to handle this problem ?
Thank you !
Have you flushed the rewrite rules yet?
Go to Settings -> Permalinks and hit save.
Alternatively, you can do it from your theme by calling the flush_rewrite_rules() function.
As I needed to use the directory on my other HDD for every dev project, I changed the Server root of Apache2 and it resolves my problems
Related
Just got a new dedicated server from a reputable hosting company for my new website project.
It runs Centos 7.9/WHM with Apache 2.4+PHP 7.4 Package.
PHP-FPM as handler.
I ran some test with some php files in my website folder and I noticed that any .php files is accessible without his extension. Without any .htaccess file!
"https://www.example.com/myinfo.php" is Accessible.
"https://www.example.com/myinfo" Should be inaccessible without any .htaccess + rules.
It's annoying me a lot because I know it's gonna bring me some issues during my website project.
Where could these rule be as I am not using any htaccess file?
Thanks for any information you can give me.
As Magnus Eriksson said: You could be having multiviews enabled in your vhost. Try turning them off, restart apache and check if the issue is resolved. There could also be rewrite rules directly in your vhost.
As you have cPanel installed, my guess is the /etc/httpd/httpd.conf, and /var/cpanel/templates/apache2_4/ea4_main.default. Before you edit the ea4_main.default, copy it to ea4_main.local: cp -a /var/cpanel/templates/apache2_4/ea4_main.default /var/cpanel/templates/apache2_4/ea4_main.local, and only edit the ea4_main.local file. Please be careful when editing it, as it could mess up a lot of things. I would suggest you to ask questions on cPanel Forums if you are using cPanel, because this must be a cPanel related issue. And, I am not responsible if any problems occur, I have warned you already.
Edit:
Since you linked your httpd.conf file, I found this:
<Directory "/">
AllowOverride All
Options MultiViews FollowSymLinks IncludesNOEXEC Indexes ExecCGI
</Directory>
Change it to:
<Directory "/">
AllowOverride All
Options -MultiViews +FollowSymLinks +IncludesNOEXEC +Indexes +ExecCGI
</Directory>
I have uploaded all my project files onto my cloud machine in the drectory /var/www/html/.
When I visit the IP address of this machine through a browser, it shows me the expected page, which routes to MyCtrl/index.
However, if I manually go to IPAddr/MyCtrl/index, I get an apache server 404 error.
None of the other routes work either. eg. IPAddr/MyCtrl/someOtherAction results in a 404 as well.
The fact that the homepage loads means that the default configuration for MyCtrl/index is working, but maybe URL rewriting is not being done right?
Can someone tell me whether the problem is with my bootstrap.php file or with my .htaccess file, along with a possible fix?
It's the first time I'm deplying an application onto a cloud machine, so I'm not really sure what the problem is.
So if anyone has the same issue, here's the fix:
(This is considering that all project files are in /var/www/html/
Changes have to be made in /etc/apache2/apache2.conf
From:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
To:
<Directory /var/www/>
Options All
AllowOverride All
Require all granted
</Directory>
This answer helped me out:
Kohana The requested URL /home was not found on this server
in my apache sites-available/default file i had change the config to folowing:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All //originally was AllowOverride None
FallbackResource rewrite.php //i added this line, too
Order allow,deny
allow from all
</Directory>
i wanted to handle all url calls in my own rewrite.php file. this works, when i visit my site at http://192.168.1.104:4567/web/knxzkcha but doesnt work when i go for http://192.168.1.104:4567/web/. i got this problem in firefox : The connection to the server was reset while the page was loading.
the index site http://192.168.1.104:4567/web/index.php works flawlessly and shows me my index.php file. all i want is to let me show the index file when visiting the root directory, too. /var/www points to the /web directory. i have some ubuntu 12.04 server 64 LTS edition
when i rewert the config lines, the root gives me the index file by default.
You do not need to add AllowOverride All, telling apache to avoid IO by checking existence of .htaccess files in current directory and all parents directories with AllowOverride None is a good recipe for speed. Avoid .htaccess files if you can edit Apache configuration.
Now FallbackResource is a quite new feature and may have some bugs. Did you check the ErrorLog for details? Could you try that with LogLevel debug?
It seems you problems is with directories, maybe you could fix it by enforcing usage of your fallback when a Directory is requested, try to add:
DirectoryIndex rewrite.php
I have developed a site in CodeIgniter, it was working perfectly in my old server as I have changed new server which is in GoDaddy it gives the following error:
Not Found
The requested URL /Foldername/authorise was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache Server at "siteurl" Port 80
actually this process coming after login in this site
Thanks in advance
Did you remember to also move the .htaccess ?
It sounds like a rewrite-problem.
Did you change the base_url in the application/config.php as per new server.
Or if there is mod rewrite problem then follow the steps:
copy rewrite.load and ssl.load from mods-available to mods-enable.
copy default-ssl from sites-available to sites-enable and change as
From:
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
To:
Options Indexes FollowSymLinks MultiViews
RewriteEngine On
AllowOverride all
Order allow,deny
allow from all
To make .htaccess files work as expected, you need to edit this file:
/etc/apache2/sites-available/default
Look for a section that looks like this:
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it's okay to allow .htaccess files to over-ride previous directives. You must reload Apache before this change will have an effect:
sudo /etc/init.d/apache2 reload
I have built a Zend Framework application. By configuring it to read routes.ini file, my application after deployment is not going to any routes but only default route is working. I have total of 4 routes in this application and none of them are working. Apache is showing a Not Found error.
I had look at .htaccess file it is perfect and in my local it is working fine. I also checked the permissions. It is having read and write rights for www-data. I also checked Apache URL rewrite module.
I did this again and tried:
sudo a2enmod rewrite
Still same issue.
My apache error log says that file does not exist.
Please tell me where I have gone wrong.
After researching for hours , I could notice that there was a very minor and sensitive mistake in the apache vhost file .
my entry was like this
<Directory /var/www/your_project>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
But actually my entry should be as per mssb some what like this
<Directory /var/www/your_project>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory
Since I am not an experienced webmaster I couldn't noticed one simple thing which is
AllowOveride option which was set to None
I referred to Core apace documentation today in order find where I was wrong .
The reason for not picking .htaccess file is as follows
When AllowOveride directive is set to None, then .htaccess files are
completely ignored. In this case, the server will not even attempt to
read .htaccess files in the filesystem.
When this directive is set to All, then any directive which has the
.htaccess Context is allowed in .htaccess files.
I personally felt like Posting this entire solution for the problem to help others who may face a similar problem in future
Once again I would like to thank you all for responding to this post
Try following steps to mod_rewrite
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
sudo gedit /etc/apache2/sites-enabled/000-default
add following codes
<Directory /var/www/your_prject_name>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
# Commented out for Ubuntu
#RedirectMatch ^/$ /apache2-default/
</Directory>
then restart the server
sudo /etc/init.d/apache2 restart