我打包了我的一个项目,它运行良好。但是当在路由/about上点击刷新时,它显示“所请求的URL /about在此服务器上未找到”。但是,当我在本地主机上使用Web服务器时,在刷新和前进/后退按钮上,它可以正常工作。我在客户端路由中使用react-router。
以下是客户端路由代码,但我怀疑这不是问题所在
Router.run(routes, Router.HistoryLocation, function (Handler) {
React.render(<Handler/>, app);
});
而我的路线就在那里:
let routes = (
<Route>
<Route name = "App" path="/" handler = {App}>
<Route name="About" path="/about" handler = {About}/>
<DefaultRoute name="Projects" handler = {Projects}/>
</Route>
</Route>
);
这是我认为我损坏的APACHE:
<Directory /var/www/>
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
Require all granted
#RedirectMatch ^/$ /apache2-default/
</Directory>
kkotwal.me.conf:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#
ServerName kkotwal.me
ServerAlias www.kkotwal.me
ServerAdmin webmaster@localhost
DocumentRoot /var/www/kkotwal.me/public_html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
index.html
文件在同一文件夹中的.htaccess
文件中,但你可能希望将其包装在一个<IfModule mod_rewrite.c></IfModule>
标签中。 - aviemet