Member Avatar

RudyM

Hi again,

So I finally get a live site set up locally for development and it's mostly ok. What I just noticed is that the links do not seem to work. So I go to the permalink settings through the dashboard, just to view, and suddenly Voila! All links work now upon clicking to view permalink settings without any changes. What's causing this? Should I remove this from the table and add it back in to simulate the same?

Hello,

I noticed your other posts about this recently and thought this might be a little late but will really help.

The best way I have found to allow me to develop a word press site and be able to transfer it to production without having to edit the database is to trick the computers working on the development system into thinking it is the production server. You do this by editing the hosts file (Linux - /etc/hosts, Windows - C:\Windows\System32\drivers\etc\hosts ) to point the domain name to the IP address of the development server. This is a text file with no extension and you will need to be either root or an Administrator to edit the file.

For example: I have a development server on my internal network at 192.168.0.10 and my production server is at 54.148.71.11 hosted at amazon. I edit the hosts file on the development server and any system that needs to access the development environment to have the additional line

192.168.0.10 txlinux.com

When your computer does domain name lookup for an IP address it first checks the hosts file and if it does not have an entry then it checks the local DNS server. You have to edit the hosts file on the computer you are working from so it initially redirects to the development address. You have to edit the hosts file on the development system so it will not redirect the site to the production system because of the way wordpress is designed. When you need to access the production system from your computer you can simply put a # in front of the line, making it a comment and your system will ignore it. You do not have to reboot to get this to take effect normally but on the development server I have made it a practice..

Then to make changes to the production system you simply copy the files and database without modifications.

Hope this helps.

Member Avatar

RudyM

Thanks RCH1231, this helped clear it up. I think disabling the plugins helped. One of them was handling the redirects for SEO purposes, and this was causing the issue for me. Thanks again for the follow-up.

Member Avatar

RudyM

So I'm trying to do something similar from the command line using wp-cli:

wp rewrite flush --path=c:\xampp\htdocs\mywordpress

But this will not do it.

Member Avatar

RudyM

Basically, I would like to do something to simulate viewing the permalink settings from the WordPress dashboard so that the site links can work. The previous command doesn't work. And I have tried:

wp cache flush --path=c:\xampp\htdocs\mywordpress

to no avail. I would rather not have to log in just for this purpose. Thanks!

Member Avatar

RudyM

chris n teddy, not sure why you were -1, but I'm glad this helped. Can you elaborate on the issue you had for which this helped? Thanks.

Member Avatar

RudyM

I think this permalink issue comes up whenever I deploy a WordPress backup file locally on my machine.

Member Avatar

RudyM

Ok, so ugly solution is to script this in vbscript and lauch the permalinks page and then close it. This will suffice until I find a better solution.

Member Avatar

RudyM

So the real solution is the check the .htaccess file. This is edited upon viewing the permalink settings. It should look like:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mywordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mywordpress/index.php [L]
<IfModule>
# END WordPress

So I just keep a local copy and copy it over to the local wordpress folder as a final step and Voila!