404 error after website migration - php

I developed a website using CodeIgniter on a server, and I'm trying to migrate it to the production server but I'm getting a 404 error. Again, the website is working perfectly on the development server so all I did was copy the files and the database from one server to the other.
Here is the .htaccess file of the website folder (copied from the original installation):
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
On the original server, the main URL was http://myowndomain.com/websitename/preview
Now it should be like http://www.websitename.com/preview
So yes, the website is in a subfolder in both cases, and the fies are exactly the same. I also checked the Apache configuration using "phpinfo()", and I can see that the "mod_rewrite" module is loaded.
The home page is working though ( http://www.websitename.com/preview ), it's able to run the index.php file, but all the links on the page don't work.
What am I missing?
Thanks

Related

extensionless url opening in Apache results in not found when file exists

I have the following setup:
Wamp server with Apache 2.4.27, PHP 7.1.8
Then I am using our own CMS to develop a website.
It is installed in the www folder under PeerCMS$/test/ ($ to hide it in wamp overview)
Now I am browsing to http://localhost/PeerCMS$/test/structure
This is working fine. It displays our CMS stucture page to generate a database. When we save this, it will be saved to stucture.json in the same test folder.
After this, http://localhost/PeerCMS$/test/structure isn't reachable anymore. 404 Not Found.
If we remove the .json file, it is reachable again.
This is our .htaccess:
RewriteEngine On
RewriteBase /PeerCMS$/test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
I think that one is ok.
Does anyone know where to look for this?

Not able to redirect my pages to index.php in WAMP SERVER

I have copied my code from LINUX (which is perfectly working) to Windows where I am using WAMP server to practice web development. I don't understand why my pages are not being redirected to index.php.
dev.mysite.com is working and showing my home page, which means doc root is correct and working fine. Later pages are showing 404 because of this redirect issue. Below is my .htaccess, can someone please check and advice, where I am doing wrong?
For example, if I am trying to access dev.mysite.com/contr1/action1 I am getting 404 not found.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(\d{4})/(0?[1-9]|1[0-2])/([^/]+)/?$ app/$1-$2/$3 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
For Local Development servers you cannot use tld's like .com, .org, .net, etc. without doing additional very complex things, which I will not go into. See this well explained tutorial on setting up Virtual Hosts, hosts file, etc. in WAMP: https://john-dugan.com/wamp-vhost-setup/

.htaccess file work fine on localhost but generates 404 error on testing server

I am developing a system which redirects all requests to an index.php file using .htaccess
DirectoryIndex public/index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!public/).+)$ public/index.php?cmd=$1 [QSA,NC,L]
Which works fine when I am running the system locally via XAMPP but when I upload it to a remote testing site, its only able to load the homepage but when I click any other link it generates a 404 error.
What could be the issue?
Thanks
Did you enable the use of .htaccess files on the remote server? I doubt it's that Mod_rewrite is not enabled because you'd get a 500 internal server error so most likely your .htaccess is not getting read at all.
Check your vhost config and make sure you have
AllowOverride All

Wordpress: stuck after installing Wordpress and copying in wp-content directory

Completely new to Wordpress and I am working on a collaborative project however I am having trouble getting up and running.
This is what I have done so far...
Installed MAMP.
Went to PHPmyadmin and created a database (e.g. myblog).
Downloaded Wordpress.
Copied and pasted existing wp-content into my downloaded Wordpress folder in htdocs and also renamed that folder from 'wordpress' to '/myblog'.
Went to localhost selected /myblog.
Installed Wordpress
Went to dashboard click visit site.
Now getting Not Found
The requested URL /myblog/lessons/orientation/ was not found on this server.
Would anyone know what I am doing wrong here?
You need to add the htaccess rewrite rules for WordPress to your MAMP server. Without these rewrite rules, the browser request doesn't actually get routed to be handled by WordPress.
# 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
In MAMP, you have to add these rules in the MAMP app itself and not in an .htaccess file (unless you specifically configure MAMP to allow that).
Here is a screenshot of where to do that in MAMP 2, the field is called "Customized Virtual Host Directory Settings"
Dashboard>Settings>Permalinks try changing your permalink setting.

Directory outside Wordpress delivering 404 -- just on subdomain

I have a very basic Wordpress install, with WP in root and permalinks on. For external directories I set up, things are working fine, no matter what's in them.
BUT, I recently replicated the site on a subdomain, to use as a dev site. That site has its own files, and its own database. On it, any php files in external directories are resulting in a WP-served 404 error. It serves html files within those directories just fine.
To recap:
mysite.com -- Wordpress site, all is fine
mysite.com/kitties/file.html --> html file outside of WP, fine.
mysite.com/kitties/file.php --> php file, outside WP, fine.
dev.mysite.com --> Wordpress site, all is fine
dev.mysite.com/kitties/file.html --> html file outside of WP, fine.
dev.mysite.com/kitties/file.php --> php file outside of WP, returns WP-served 404
My .htaccess file is below, and standard, but given that the problem is only on the dev site, I don't know that it has anything to do with htaccess, and wonder if it's an apache configuration issue?
# 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
When Moving / duplicating a site it is usually wise to resave the permalink settings, even when nothing changes.
Did you change the url in the settings of wp-config?
After that it is also wise to check the database for urls (tool).
Try those and see if the problem still exists.

Categories