You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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 new HTDOCS/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

  1. Create a new folder named mylocalsite in your HTDOCS directory
  2. Copy all files and folders from HTDOCS/wordpress/ into HTDOCS/mylocalsite/
  3. Double-check your wp-options table to confirm both siteurl and home options are set to http://localhost:8888/mylocalsite/ (it’s easy to accidentally miss one!)
  4. 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:

  1. Open MAMP’s Apache config file: /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
  2. 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>
  1. Edit your local hosts file (found at /etc/hosts on macOS/Linux, C:\Windows\System32\drivers\etc\hosts on Windows) and add this line:
127.0.0.1 mylocalsite.local
  1. 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.php file to override any database inconsistencies:
define('WP_HOME','http://localhost:8888/mylocalsite/');
define('WP_SITEURL','http://localhost:8888/mylocalsite/');
  • Reset .htaccess: Delete your existing .htaccess file (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 .htaccess file
  • 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:18:38