I have hosted a domain in Linux Apache 2.4.16 web server and installed WordPress in it. Now I cannot update Permalink from default (date/time/%postname%/) to /%postname%/ or custom structure. Only Plain type gets saved. I am getting 404 error.
404 Page not found
I have cleared everything in the server contents, posts, plugins, even ssl too and remove and install WordPress,... But I am still getting the same error.
Any suggestions?
Seems all the things you did are correct in this context. Have you checked whether the mod_rewrite module is on in Apache. You can check that by writing the phpinfo function in a file at your server.
Check Screenshot
Read
Give permission to .htaccess file. Through Linux command line. At first navigate to the project folder,
cd /var/www/html/project-folder
Then give 777 permission to .htaccess file. By this below command,
sudo chmod -R 777 .htaccess
Then edit .htaccess file with the below code.
# 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
And then update the permalink settings 2 times from the wordpress admin panel.
Related
I've created a laravel project which is working fine on localhost and my hosting server but when I upload it on my client's server it just doesn't work (he's using bluehost).
When I open the URL which is pointing to /public folder, it should display the homepage. Instead it is showing the listing of all files and folders (except public folder).
When I try to open myurl.com/public or myurl.com/public/index.php in browser, it gives following error:
Forbidden
You don't have permission to access /license/public/ on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I can see public folder via FTP and I've changed permissions for /app/storage to 777
Here is my public/.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I've checked my /public/error_log, its showing following error:
[21-Aug-2015 09:06:01] PHP Fatal error: require() [<a href='function.require'>function.require</a>]: Failed opening required '__DIR__/../bootstrap/autoload.php' (include_path='.:/usr/lib64/php:/usr/share/pear') in /home6/parentv3/public_html/eldercareapp/license/public/index.php on line 21
Any help?
Well the problem is with your PHP version. If you see your PHP Version, you might get what is wrong with your application. You must use version greater than PHP 5.5
Ok, I had contacted client's hosting company and asked them to upgrade PHP version. They took a couple of days and upgraded PHP to 5.5.
But the problem was still there even after updating PHP. I wasn't able to access /public folder so the problem was somewhere else. After some searching and trying I've found a solution.
The problem was actually in my /public/.htaccess file. I've added just one line in my .htaccess and it solved the problem: Options +FollowSymLinks
My updated .htaccess in /public now looks like:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Cheers
Changing permissions to 777 is a terrible idea because it will be vulnerable, instead try with sudo chmod -R 775 project/ where project is the name of your project's folder, then do the next sudo chown -R $USER:$USER project/ to make the project's folder be owned by your user, finally, if you haven't done it, cd into the project's folder and run composer install
I read lots of the mod_rewrite for codeigniter and lots of them were talking about creating a .htaccess file and inside the file with something like
I'm a beginner with codeigniter so I'm learning from youtube tutorials.
at first I only have apache 2.2 installed to run my php and after using codeigniter with mod_rewrite I realize it's easier to install wamp so I uninstalled apache, mysql then installed wamp which has everything.
After that I continued with the tutorial on youtube about mod_write. I activated the module in wamp.
Created this .htaccess file inside ci_intro which is the root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ci_intro/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
I went to the config/config.php and changed
$config['index_page'] = '';
things didn't work. I was getting the 404error then I was trying out few things in
RewriteBase /ci_intro/
and also even deleted the whole project and because I backed things up right before I try the mod_write. Even after I retrieved the backup. I still didn't get the error404 page.
I just keep on getting..
Since I'm using wamp, when I go to my localhost there's a section saying my project which is ci_intro...I click on it the image above comes out.
I put my mouse over to check what's the link showing when mouse over and the link shows
[CODE]http://localhost/ci_intro[CODE]
anyone know what's going on here?
That browser page you are getting, is a result of using a fake or unregistered domain-name... The browser is unable to resolve it to an IP address, so it "helps" you by reinterpreting your request as a search term.
This is happening because you are using "www.domain.tld" instead of "localhost" to access your website.
I'm not sure which WAMP distrubution you are using (there are many "WAMPs"), but your options are:
A) Edit the Windows Hosts file (C:\Windows\system32\drivers\etc\hosts) to locally resolve "www.domain.tld" to the local IP addres 127.0.0.1 (and make sure your VirtualHost or Server has that domain name as part of it's ServerName directive).
B) Use "localhost" instead... http://localhost/
C) Use a WAMP that automatically sets up website VirtualHosts for you and has a LocalDNS feature like Wamp-Developer Pro does - so none of the above matters.
Now once you get passed that, there might be some other issues... I'm guessing that .htaccess file should be in the DocumentRoot folder itself.
I know there are a few of (probably) the same questions out there, but I just can't find any working solution.
I've placed the .htaccess file next to my index.php on the server.
And even if the .htaccess is empty the site returns error 403 (forbidden access).
What I wanted to do is remove the .php extension.
http://foo.net/web_new/index_1024.php
And even if I put the following into the .htaccess, the website still returns error 403.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
</IfModule>
I've found on the web, to enable the mod_rewrite, I should enable it in httpd.conf. But I search the whole server (ftp), but there is no clue.
where phpinfo() finds conf.d file
/etc/php5/conf.d
where is my root
/srv/www/web6/
Any idea, what could i do?
Make sure that .htaccess has 644 permissions
I think you can remove that ifModule... I find it "messy" there...
Your code looks well...
My client has asked for a cake php app i've made for them to go into a sub directory on their existing server.
All works perfectly on my test remote and local installations.
Initially I had a problem with htaccess and had to add RewriteBase /quotesystem/ to my htaccess files in order to see the site at all. So I have changed my htaccess as below:
cake root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /quotesystem/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
app .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /quotesystem/app/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
and webroot .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /quotesystem/app/webroot/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>
Now I can access my site but i get loads of warnings about the temp directory:
Warning (2): SplFileInfo::openFile(/web/sites/_p/_e/_t/petersen-stainless.co.uk/public/www/quotesystem/app/tmp/cache/persistent/cake_core_cake_en-gb) [function.SplFileInfo-openFile]: failed to open stream: No such file or directory [CORE/Cake/Cache/Engine/FileEngine.php, line 295]
You can see it here: http://www.petersen-stainless.co.uk/quotesystem
Now, i've CHMOD the temp directory to 777 so everyone should have permissions but i still get these errors.
I've deleted all of the files in these folders so that the temp directories have been cleaned.
When I use my ftp client - transmit - to look at the file permissions the owner appears as (?) and if i try to change it i get an error:
Could not change owner of “tmp”. Server said: 'SITE CHOWN' not understood
I dont get this with any other site I work on.
I don't understand enough to know what is going on, is this a permissions problem or an .htaccess problem or both? Or is it a server configuration problem?
If anyone can help shed some light on this and help my understanding i'd be very grateful.
UPDATE:
My directory structure on the server is as follows:
-- public
--- www
----- quotesystem
------- lib
------- app
--------- config
--------- webroot
In my experience, the SplFileInfo warning appears when Cake attempts to read/write cache that it does not have permission to access. Make sure your application has permission to read/write the cache/tmp folder (depending on your Cake version).
It's probably a .htaccess problem. The RewriteBase should be the same for both the webroot and app .htaccess. So the line in both files should be:
RewriteBase /quotesystem/
I personally never touch the .htaccess in the Cake root directory as it doesn't seem to be necessary to alter anything there.
In addition, /tmp/cache and it's subdirectories should be writable as well.
My problem is that The RewriteRule is still matching when I visit a physical directory, e.g. http://a-domain.com/foo/ where foo is a normal directory in the web root.
the .htaccess file has:
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .? index.php [L]
It works fine on my dev server but not on a live WHM/CPanel server. I'm a bit lost.
I've tested this on my cpanel website and you're right and I found out where's the problem. when you try to access a folder in your website that doesn't have default file (index) , it tries to access the file that is responsible for 403 HTTP code, and because that doesn't exist, it rewrites URL to index.php.
All you have to do is add this to above of your .htaccess file:
ErrorDocument 403 /index.php?type=err&code=403
I tried this on a VM which mirrors my own shared service and it works fine for me. Have you got another .htaccess in the foo directory? If so, then the rewrite engine will ignore your one in DOCROOT and use this instead?
The /foo/ dir has basic authentication so it was failing when %{REQUEST_FILENAME} contained a non-existent file /home/the_user/public_html/401.shtml. I didn't think this was an issue because the basic authentication worked, and when I cancelled the auth prompt I was being served a standard 401 file. Usually when those ErrorDocument files are missing, Apache says Additionally, an error of type 404 was encountered while trying to use an ErrorDocument to handle the request.