我需要在本地设置项目,以便在我的工作中进行生产。几乎每一页都会抛出404 f.e http://localhost/project1/producers/wear.html。它发生在Ubuntu和Windows上。
我的项目位于var / www / html / project1下,在http://localhost/project1/下可见,在http://project1/
下可见log / apache2 / access.log显示404:
127.0.0.1 (..)"GET /project1/shop/clothing.html (..)" 404 17601 "http://localhost/project1/"(..)
127.0.0.1 (..)"GET /public/css/font-awesome.min.css (..)" 404 521 "http://localhost/project1/shop/clothing.html"(..)
127.0.0.1 (..)"GET /public/css/bootstrap.min.css (..)" 404 518 "http://localhost/project1/shop/clothing.html"(..)
127.0.0.1 (..)"GET /public/js/jquery-2.1.4.min.js (..)" 404 518 "http://localhost/project1/shop/clothing.html"(..)
127.0.0.1 (..)"GET /public/js/bootstrap.min.js (..)" 404 515 "http://localhost/project1/shop/clothing.html"(..)
127.0.0.1 (..)"GET /public/js/base/frontend.js (..)" 404 515 "http://localhost/project1/shop/clothing.html"(..)
127.0.0.1 (..)"GET /files/graphics/logo.png (..)" 404 512 "http://localhost/project1/shop/clothing.html"(..)
apache2.conf:
Mutex file:${APACHE_LOCK_DIR} default
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
PROJECT1 / htaccess的:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
<IfModule pagespeed_module>
ModPagespeed off
</IfModule>
PROJECT1 /公共/ htaccess的:
Options -Indexes
RewriteEngine off
PROJECT1 /上传/ htaccess的:
Options -Indexes
RewriteEngine off
PROJECT1 /系统/ htaccess的:
deny from all
project1 / application / .htaccess(controllers,entities):
deny from all
HTML样式src也是f.e。:
<link rel="stylesheet" href="public/css/bootstrap.min.css">
编辑:
输入var / www / .htaccess后:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ /project1/$1 [R=301,NC,L]
我可以访问project1 / public /中的样式,js文件:
127.0.0.1 "GET /project1/shop/supplements.html" 404 17608 "http://localhost/project1/new.html"
127.0.0.1 "GET /public/css/bootstrap.min.css" 301 626 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /public/js/jquery-2.1.4.min.js" 301 627 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /project1/public/css/font-awesome.min.css" 200 6580 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /project1/public/css/flag-icon.min.css" 200 3113 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /project1/public/css/ilightbox.css" 200 1848 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /public/js/base/frontend.js" 301 621 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /project1/public/js/jquery.requestAnimationFrame.js" 200 1001 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /files/graphics/logo.png" 301 615 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /project1/public/js/base/frontend.js" 200 1195 "http://localhost/project1/shop/supplements.html"
127.0.0.1 "GET /project1/public/fonts/materialdesignicons-webfont.woff2?v=1.7.22" 304 182 "http://localhost/project1/public/css/materialdesignicons.min.css"
::1 - - [11/Jun/2017:11:51:01 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g (internal dummy connection)"
但项目中的每个站点仍然是404,f.e。 http://localhost/project1/bestsellers.html
登录access.log
127.0.0.1 "GET /project1/bestsellers.html HTTP/1.1" 404 17608 "http://localhost/project1/recommended.html"
并且每个页面都会抛出Uups... Page not found!
但是有一个STYLE!至少:))
答案 0 :(得分:1)
看起来您的应用程序并非设计为在子文件夹中运行,如果这是您正在运行的唯一项目,则可以添加.htaccess以重定向回到projects文件夹,将其放入{ {1}}
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*)$ /project1/$1 [R=301,NC,L]
或者,您只能查找特定目录
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/(.*)$ /project1/public/$1 [R=301,NC,L]