WordPress(MAMP环境)无法重定向至自定义路径问题求助
Hey there, let's troubleshoot this redirect issue with your local WordPress site on MAMP—this is a super common hiccup when moving sites locally, so I’ve got a few fixes to walk you through:
First: Fix the core path mismatch (most likely culprit)
You mentioned you set your site URL to localhost:8888/mylocalsite/ but stored all site files in HTDOCS/wordpress/. These two paths don’t line up, which is why WordPress is still trying to route you to /wordpress/. Here’s how to fix it:
- Either: Move all files from
HTDOCS/wordpress/into a newHTDOCS/mylocalsite/folder (so your file structure matches the URL you set) - Or: If you want to keep the files in
/wordpress/but use/mylocalsite/as the access URL, set up a virtual host in MAMP (details below)
Option 1: Adjust file path to match site URL
- Create a new folder named
mylocalsitein your HTDOCS directory - Copy all files and folders from
HTDOCS/wordpress/intoHTDOCS/mylocalsite/ - Double-check your
wp-optionstable to confirm bothsiteurlandhomeoptions are set tohttp://localhost:8888/mylocalsite/(it’s easy to accidentally miss one!) - Clear your browser cache + cookies, then reload the site
Option 2: Set up MAMP virtual host (keep files in /wordpress/)
If you prefer to keep your files in the wordpress folder but use /mylocalsite/ as the access point, configure a virtual host:
- Open MAMP’s Apache config file:
/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf - Add this block at the bottom (adjust paths if your MAMP is installed elsewhere):
<VirtualHost *:8888> DocumentRoot "/Applications/MAMP/htdocs/wordpress" ServerName mylocalsite.local <Directory "/Applications/MAMP/htdocs/wordpress"> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> </VirtualHost>
- Edit your local
hostsfile (found at/etc/hostson macOS/Linux,C:\Windows\System32\drivers\etc\hostson Windows) and add this line:
127.0.0.1 mylocalsite.local
- Restart MAMP’s Apache server, then visit
http://mylocalsite.local:8888—it should route correctly now
Additional checks to rule out other issues
- Force site URL in wp-config.php: Add these lines to your
wp-config.phpfile to override any database inconsistencies:
define('WP_HOME','http://localhost:8888/mylocalsite/'); define('WP_SITEURL','http://localhost:8888/mylocalsite/');
- Reset .htaccess: Delete your existing
.htaccessfile (in your site root), then log into WordPress admin (if you can) and go to Settings > Permalinks—click "Save Changes" to generate a fresh, correct.htaccessfile - Clear caching: If you had a caching plugin installed on the live site, delete its folder from
wp-content/plugins/(old cache files can mess up local redirects)
内容的提问来源于stack exchange,提问作者user9504869
相关产品推荐
相关产品推荐

