XAMPP Wordpress安装无法找到图片/文件

I've cloned my website to xampp for a local version. My WordPress site is located in C:/xampp/htdocs/my-website.

I've also cloned my database to local and changed the urls from the web to http://localhost/my-website.

I've made a .htaccess file and already set xampp overwrite all in httpd.conf that the file won't be ignore.

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

I can see my website with http://localhost/my-website but all my .js, .css, .png etc. files can't be found. I looked in network analystic from Firefox and the links are not complete.

This is the wrong link:

http://localhost/wp-content/themes/storefront/startseite.js

But it should look like this:

http://localhost/my-website/wp-content/themes/storefront/startseite.js

I've searched a lot in google but can't find a solution. Hope you know a answer.

Thanks guys!

</div>
donglu3243
donglu3243 有人知道答案吗?
3 年多之前 回复

2个回答

changed the urls from the web to http://localhost/my-website....

How did you do that? In wp_options? Or Appearance>>General Settings?

You should use interconnectit.com WordPress Serialized PHP Search Replace Tool to change all URLs in the database options and in post/page content. That tool will correctly change all URLs and it also correctly deals with serialized data in the database.

And, after you make a directory or folder move of a WordPress site, resave permalinks in Settings>permalinks. That will write the correct permalinks to .htaccess.

Also see Moving WordPress « WordPress Codex

doureng1083
doureng1083 不知道.....
3 年多之前 回复
dongpu8935
dongpu8935 我试着用旧的htaccess去wp-admin。 比删除内容并保存永久链接。 Wordpress用完全相同的条目写了一个新的htaccess,问题仍然存在
3 年多之前 回复
douguxun6866
douguxun6866 但是没有htaccess文件,我的条目从问题的顶部开始我无法打开后端,因为xampp没有重定向到我的网站没有它
3 年多之前 回复
dongzhanbi0027
dongzhanbi0027 您在.htaccess中的永久链接块可能不正确。 最好的办法是从WP后端重新保存永久链接,以便WP可以正确地编写它们。
3 年多之前 回复
doushifen4060
doushifen4060 我已经使用我的数据库中的搜索和替换工具以及常规设置完成了此操作。 我也重新锁定了我的永久链接。 但网址仍然是错误的。 在我的php文件中,我简要地写道:<script type =“text / javascript”src =“/ wp-content / themes / storefront / styleswitcher.js”> </ script>但我网站上的输出是http:// localhost /wp-content/themes/storefront/styleswitcher.js但它应该看起来像http://localhost/my-website/wp-content/themes/storefront/styleswitcher.js
3 年多之前 回复

I found a solution. I have to make a virtual host for my site. Here are the 4 steps you have to do:

  1. Go to C:\xampp\apache\conf\extra\httpd-vhosts.conf and make two new hosts. First set up a localhost so that when you want to call another folder which is no virtual host work:

#localhost
<VirtualHost *:80>
  DocumentRoot "C:/XAMPP/htdocs"
  ServerName localhost
</VirtualHost> 
#My Website
<VirtualHost *:80>
  DocumentRoot "C:/XAMPP/htdocs/my-website" #your path to your installation
  ServerName my-website.dev #Change my-website to your wish name/url
  ServerAlias my-website.dev #Change my-website to your wish name/url
</VirtualHost>   

  1. Go to the Windows hosts file and add this:

    127.0.0.1       my-website.dev
  1. Go to your Wordpress .htaccess file and paste this into it:

# 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

You have to save all files and restart your Apache and MySQL Server

  1. Now you have to change all Worpdress url's in your database to http://my.website.dev. To make this step easy you've to download the Database Search and Replace Script in PHP from https://interconnectit.com/products/search-and-replace-for-wordpress-databases/. Unzip this and paste the folder Search-Replace-DB-master in C:/XAMPP/htdocs. Open your browser and go to this url: http://localhost/Search-Replace-DB-master/. Now enter your database informations in the database section (db-name, user, passwort). Go to the top and enter in the replace field your old url (in my situation: https://my-website-old-url.com) and in the field after with your new url (in this situation: http://my-website.dev).

Now click on live run in the middle of the page and all of your old urls will replaced with the new one.

Finaly go to the browser and enter your new url: my-website.dev

Thats it! Hope I can help someone with this.

</div>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐