I have a rather strange issue with my website. I have just decided to remove my website from one server to a new server (I no longer wanted to use wpengine.co.uk)
I have now got the site up and running however the only issue I have is if I set the "permalinks" option to "post name" as can be seen here: http://i.imgur.com/poyRQ9x.png then I get a 404.
I have the following Apache setup on a Linux box:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
My .htaccess looks like this (for now I have set the file permissions to 666):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Lastly I have enabled as can be seen from my "phpinfo()" page.
The site does work if I use the ugly looking "plain" option... but that is obviously something I don't want.
Reboot Apache after making changes to httpd.config. (Changes to pph.ini and .htaccess don't require reboots).
And, you may need to add AllowOverride All for the document root:
<Directory /var/www/html>
# ... other directives...
AllowOverride All
</Directory>
Please remove your .htaccess file from wordpress root directory, then try to change permalink setting.
Note :- backup .htaccess file before delete it.
I hope this will work for you.
Well the answer turned out to be rather strange. It appears that for this to work I needed to install some extra PHP extensions. All I needed to do was:
sudo apt-get install php-mbstring php7.0-mbstring php-gettext
Although I think that the one that finally worked was:
sudo apt-get install php-curl
I saw warnings about this but I had no idea that that would actually stop WordPress's redirection. If somebody knows why this is the case I'd be really grateful to know.
Related
I have correctly setup my site locally and everything works. However, when I deployed that to a blank EC2 instance, I see that wp-json (Rest API) does not work. It works only when I put an index.php in between. In other words
This works locally:
http://localhost/wordpress/wp-json
But I need to have this on the EC2 server to make it work.
http://A.B.C.D/wordpress/index.php/wp-json
On the server, I have installed apache2 and I have not messed up with the configs yet. I am familiar with wordpress but I not so much familiar with config tweaks on apache. I have also gone thru thousands of previously posted questions, but none of them seem to answer my problem.
First, you need to have by a2enmod rewrite in your terminal.
Then in your Apache Configuration file, make sure you have the following:
<Directory #Wordpress directory here#>
Options Indexes FollowSymLinks
AllowOverride All #allows .htaccess directives in the next step
Require all granted
</Directory>
Then make sure you have the following content in your root .htaccess file:
RewriteEngine On
RewriteBase /wordpress/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.+) index.php/$1 [L]
I have migrated one of my client's sites to Linode. Now the homepage is working and the rest of the pages shows "NOT Found" and "The requested URL /apk-download/ was not found on this server."
Apache/2.4.25 (Debian) Server at www.frpbypass.us Port 80
URL: [http://www.frpbypass.us][1]
I have tried to change:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Also, added the WordPress default .httaccess.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
After making the changes, I have restarted the Apache web server as well as Server reboot.
Any idea of how to fix?
Thanks in advance.
Simply go to setting -> permalink and change your default permalink setting twice.
It will change the default htaccess and your site will start working.
Finally, I am able to fix the issue. If you're experiencing the same issue then first just saving the Permalink should fix the issue. If not then try .htaccess method and finally looking for apache2.conf file.
In my case, I made all the changes as above but enabling the apache2 rewrite mod fixed my issue.
Use this command:
sudo a2enmod rewrite
Hope this helps anyone who faces the same issue. It took hours of research to finally fix the issue.
I am trying to get mod_rewrite to work by using a .htaccess file on my localhost server.
My apache2.conf file contains:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
And:
Include mods-enabled/*.load
/etc/apache2/mods-enabled/rewrite.load file contains:
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
The .so file exists.
service apache2 restart shows no warnings/errors
My .htaccess contains:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /process.php?path=$1 [NC,L,QSA]
And it's located at /var/www/wp/wp-content/plugins/myplugin/
process.php contains print_r($_SERVER);
I am visiting http://localhost/wp/wp-content/plugins/myplugin/randomstring and always getting a 404 error.
I tried changing the .htaccess file to a random string trying to trigger a 500 error to make sure the .htaccess was being "executed"(?), but still getting a 404 not found error.
var_dump(in_array('mod_rewrite', apache_get_modules())); returns true
what am i doing wrong? This always works on my online servers.
Check if the module is enabled using php_info(). If there is some errors.
Try the following command.
sudo a2enmod rewrite
I think if you change (/etc/apache2/sites-available/default) AllowOverride none to AllowOverride All then it will work.
If still you are getting the error, then do the steps mentioned here.
The tutorial is bit old, but you can get the module working.
I hope this helps.
Very new to this stuff so please be gentle with me.
I'm running a server with Debian8, and using it to host my website, Teamspeak and a bit of file storage.
After moving my server files into /var/www/html and sorting out DNS-stuff my site is up and running - but the clean URL fix I used (with the .htaccess file) no longer functions. I wanted to find out if this was a mod_rewrite issue so I tried to check using a phpinfo.php file - which kept downloading in browser instead of executing.
My .htaccess file looks as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
# Hide .html extension
## External Redirect
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,NC]
## ## Internal Redirect
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html
AddHandler php5-script .php
Things I have done:
Installed PHP5.
apt-get -y install php5 libapache2-mod-php5
and then restarted Apache
service apache2 restart
I hoped this would fix the PHPInfo.php issue, but still no success, so I attempted to edit the .htaccess file using
AddHandler php5-script .php
I'm assuming this will work but my .htaccess file isn't functioning so I figured I need to sort that first.
I checked for Mod_rewrite using
a2enmod rewrite
and was informed the module was already enabled. Okay, not a mod_rewrite issue.
Further searching led me to find /etc/apache2/apache2.conf, where I changed
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
to `
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>`
Still no dice! I also checked /etc/apache2/sites-available/ and found two files, 000-default.conf (which contains none of the above code) and default-ssl.conf (same situation). I also have /sites-enabled/ which for some reason just contains a shortcut to the previous 000-default.conf file.
I'm pretty much at my wits end now, I've Google'd this stuff to death and my poor knowledge of the workings of this stuff is clearly hindering my progress. Can anyone help?
I am using Zend Framework on Ubuntu 11.10 (my local dev machine). When I navigate to my application with this URL, the front page/index controller works fine:
http://localhost/myapp/public
So I know that for the most part everything is working. The problem comes when I try to access another controller with something like:
http://localhost/myapp/public/faq
This returns the 404 error "The requested URL /myapp/public/faq was not found on this server."
I used the Zend_Tool to create the controller like "zf create controller faq" which gave me FaqController.php with a default indexAction(). It also created the faq.phtml view. This all works just fine on my laptop (Windows XP) so I know it has to be something with configuration.
Here is my .htaccess (it's the default one):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
In an attempt to get it to work, I added this into my httpd.conf file and restarted apache:
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
When that didn't work I tried putting that directly into my .htaccess file, but that was a no-go as well. What am I missing? What is stopping Zend from being able to rewrite and route requests?
[SOLVED]
Thanks for viewing, I ended up finding the solution. With Ubuntu, in the /etc/apache2/sites-enabled/ directory is a file called 000-default which contains configuration options.
I was unaware it was there, it had all the AllowOverride options set to None so I changed them to All, restarted Apache, and voila!
To ensure anybody who finds this question via search has full help, I'd like to pass on to make sure mod_rewrite is enabled (mine was) by opening a terminal and running:
sudo a2enmod rewrite
That is how you enable an Apache mod in Ubuntu.