Drupal9.1.8通过phpStudy安装后除首页其他页面均404处理
安装
软件准备
phpStudy 8.1.1.3
Drupal9.1.8的zip包(官网下载即可)
windows系统
安装步骤
- 将drupal的zip包解压后放置到phpStudy的WWW目录下
- phpStudy开启Mysql以及Apache
- 页面访问127.0.0.1进入安装向导
- 具体参考文章:一步一步教你图文安装Drupal8
问题描述
安装完成后,访问首页,而后点击任意按钮,都是得到404的状态码。
处理
开启apache的url_rewrite模块,用于url重定向
apache配置文件位置:
在httpd.conf中去掉这句话的注释:
LoadModule rewrite_module modules/mod_rewrite.so
搜索AllowOverride None 替换为 AllowOverride All,这个地方文件里面有好几个地方有这个参数,如果不懂的话就全部改掉。
配置drupal的.htaccess文件
进入drupal根目录,发现是有.htaccess文件的,但是打开发现其内容为空,所以需要重新编写
最方便的办法:在github上找对应版本的drupal,而后将其中的.htaccess文件内容直接复制进来,我的文件内容如下
#
# Apache/PHP/Drupal settings:
## Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$"><IfModule mod_authz_core.c>Require all denied</IfModule><IfModule !mod_authz_core.c>Order allow,deny</IfModule>
</FilesMatch># Don't show directory listings for URLs which map to a directory.
Options -Indexes# Set the default handler.
DirectoryIndex index.php index.html index.htm# Add correct encoding for SVGZ.
AddType image/svg+xml svg svgz
AddEncoding gzip svgz# Most of the following PHP settings cannot be changed at runtime. See
# sites/default/default.settings.php and
# Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be
# changed at runtime.# PHP 7, Apache 1 and 2.
<IfModule mod_php7.c>php_value assert.active 0
</IfModule># Requires mod_expires to be enabled.
<IfModule mod_expires.c># Enable expirations.ExpiresActive On# Cache all files for 2 weeks after access (A).ExpiresDefault A1209600<FilesMatch \.php$># Do not allow PHP scripts to be cached unless they explicitly send cache# headers themselves. Otherwise all scripts would have to overwrite the# headers set by mod_expires if they want another caching behavior. This may# fail if an error occurs early in the bootstrap process, and it may cause# problems if a non-Drupal PHP file is installed in a subdirectory.ExpiresActive Off</FilesMatch>
</IfModule># Set a fallback resource if mod_rewrite is not enabled. This allows Drupal to
# work without clean URLs. This requires Apache version >= 2.2.16. If Drupal is
# not accessed by the top level URL (i.e.: http://example.com/drupal/ instead of
# http://example.com/), the path to index.php will need to be adjusted.
<IfModule !mod_rewrite.c>FallbackResource /index.php
</IfModule># Various rewrite rules.
<IfModule mod_rewrite.c>RewriteEngine on# Set "protossl" to "s" if we were accessed via https://. This is used later# if you enable "www." stripping or enforcement, in order to ensure that# you don't bounce between http and https.RewriteRule ^ - [E=protossl]RewriteCond %{HTTPS} onRewriteRule ^ - [E=protossl:s]# Make sure Authorization HTTP header is available to PHP# even when running as CGI or FastCGI.RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]# Block access to "hidden" directories whose names begin with a period. This# includes directories used by version control systems such as Subversion or# Git to store control files. Files whose names begin with a period, as well# as the control files used by CVS, are protected by the FilesMatch directive# above.## NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is# not possible to block access to entire directories from .htaccess because# <DirectoryMatch> is not allowed here.## If you do not have mod_rewrite installed, you should remove these# directories from your webroot or otherwise protect them from being# downloaded.RewriteRule "/\.|^\.(?!well-known/)" - [F]# If your site can be accessed both with and without the 'www.' prefix, you# can use one of the following settings to redirect users to your preferred# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:## To redirect all users to access the site WITH the 'www.' prefix,# (http://example.com/foo will be redirected to http://www.example.com/foo)# uncomment the following:# RewriteCond %{HTTP_HOST} .# RewriteCond %{HTTP_HOST} !^www\. [NC]# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]## To redirect all users to access the site WITHOUT the 'www.' prefix,# (http://www.example.com/foo will be redirected to http://example.com/foo)# uncomment the following:# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]# Modify the RewriteBase if you are using Drupal in a subdirectory or in a# VirtualDocumentRoot and the rewrite rules are not working properly.# For example if your site is at http://example.com/drupal uncomment and# modify the following line:# RewriteBase /drupal## If your site is running in a VirtualDocumentRoot at http://example.com/,# uncomment the following line:# RewriteBase /# Redirect common PHP files to their new locations.RewriteCond %{REQUEST_URI} ^(.*)?/(install\.php) [OR]RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild\.php)RewriteCond %{REQUEST_URI} !coreRewriteRule ^ %1/core/%2 [L,QSA,R=301]# Rewrite install.php during installation to see if mod_rewrite is workingRewriteRule ^core/install\.php core/install.php?rewrite=ok [QSA,L]# Pass all requests not referring directly to files in the filesystem to# index.php.RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_URI} !=/favicon.icoRewriteRule ^ index.php [L]# For security reasons, deny access to other PHP files on public sites.# Note: The following URI conditions are not anchored at the start (^),# because Drupal may be located in a subdirectory. To further improve# security, you can replace '!/' with '!^/'.# Allow access to PHP files in /core (like authorize.php or install.php):RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$# Allow access to test-specific PHP files:RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?\.php# Allow access to Statistics module's custom front controller.# Copy and adapt this rule to directly execute PHP files in contributed or# custom modules or to run another PHP application in the same directory.RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics\.php$# Deny access to any other PHP files that do not match the rules above.# Specifically, disallow autoload.php from being served directly.RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]# Rules to correctly serve gzip compressed CSS and JS files.# Requires both mod_rewrite and mod_headers to be enabled.<IfModule mod_headers.c># Serve gzip compressed CSS files if they exist and the client accepts gzip.RewriteCond %{HTTP:Accept-encoding} gzipRewriteCond %{REQUEST_FILENAME}\.gz -sRewriteRule ^(.*)\.css $1\.css\.gz [QSA]# Serve gzip compressed JS files if they exist and the client accepts gzip.RewriteCond %{HTTP:Accept-encoding} gzipRewriteCond %{REQUEST_FILENAME}\.gz -sRewriteRule ^(.*)\.js $1\.js\.gz [QSA]# Serve correct content types, and prevent double compression.RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1,E=no-brotli:1]RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=no-brotli:1]<FilesMatch "(\.js\.gz|\.css\.gz)$"># Serve correct encoding type.Header set Content-Encoding gzip# Force proxies to cache gzipped & non-gzipped css/js files separately.Header append Vary Accept-Encoding</FilesMatch></IfModule>
</IfModule># Various header fixes.
<IfModule mod_headers.c># Disable content sniffing, since it's an attack vector.Header always set X-Content-Type-Options nosniff# Disable Proxy header, since it's an attack vector.RequestHeader unset Proxy
</IfModule>
重启apache,再次访问drupal,问题解决~
Drupal9.1.8通过phpStudy安装后除首页其他页面均404处理相关推荐
- phpstudy mysql端口_完美解决phpstudy安装后mysql无法启动(无需删除原数据库,无需更改任何配置,无需更改端口)直接共存...
今天学习php,当然是要先安装好运行环境了,phpstyudy是一个运行php的集成环境, 一键安装对新手很友好,与时作为一个新手,便跟着教程安装了phpstudy集成环境. 很快安装好了,嗯.对新手 ...
- mysql删除端口配置文件_完美解决phpstudy安装后mysql无法启动(无需删除原数据库,无需更改任何配置,无需更改端口)直接共存...
今天学习php,当然是要先安装好运行环境了,phpstyudy是一个运行php的集成环境, 一键安装对新手很友好,与时作为一个新手,便跟着教程安装了phpstudy集成环境. 很快安装好了,嗯.对新手 ...
- phpstudy安装后使原本的mysql连接不上
记phpstudy安装后使原本的mysql运行不了 环境:win10 现象:安装phpstudy后本地数据库连接报错,一直连接不上.且服务中没有msyql. 原因:phpstudy和原本的mysql都 ...
- 完美解决phpstudy安装后mysql无法启动
学习php,当然是要先安装好运行环境了,phpstyudy是一个运行php的集成环境, 一键安装对新手很友好,与时作为一个新手,便跟着教程安装了phpstudy集成环境. 很快安装好了,嗯.对新手确实 ...
- phpstudy安装php8.0和php8.1的方法(内含VC运行库)
phpstudy8.1安装php8.0.14nts和php8.1.1nts的方法 phpstudy 8.1是个很好用的PHP集成环境软件,可惜官方一年多没更新了,官方只支持到PHP7.4,因为近期项目 ...
- 网络安全初学者工具安装:Kali,Windows xp虚拟机,pikachu靶场,burpsuite安装配置,phpstudy安装(学习笔记)
摘要 在互联网发展的时代背景下,网络安全成为了越来越不可忽视的重要领域,为此,各国都采取了维护网络安全的举措,对于网络安全人才的需求不断增大,我国作为世界上最多使用计算机人口的国家, ...
- XAMPP/PHPnow/phpStudy安装使用对比
一.XAMPP 1.1 下载 下载地址:https://www.apachefriends.org/download.html 1.2 安装 双击下载的安装程序进行安装,界面如下图,都是典型的下一步下 ...
- phpstudy安装及使用教程
对于程序员来说,phpstudy是一个非常好用的PHP调试环境集成包,包含了最新的Apache和PHP等程序,对学习PHP的新手来说,WINDOWS下环境配置是一件很困难的事;对老手来说也是一件烦琐的 ...
- 【LAMP】LAMP一键安装后如何检查是否安装成功
LAMP一键安装包安装成功后,如何检查是否可以正常运行? 本文以PHPstudy8.0版本为例: 一键安装讲解 安装成功后,启动程序 可选择一键启动(Nginx+MySQL) 也可以手动选择启动:(A ...
最新文章
- 【2020新书推荐】Introduction to Deep Learning
- jquery 毫秒转换成日期_jQuery Datepicker – 如何将日期格式化为纪元时间戳(以秒为单位,而不是毫秒)...
- Deeplearning 入门篇
- 没学c语言可以学python_学了Python,但是没有学c,直接去学c++是可行的吗?
- Tensorflow保存模型,恢复模型
- Kafka-Monitor
- 常用css属性集(持续更新…)
- Android开发:1-3、Android常用布局
- k8s部署tomcat及web应用_k8s部署tomcat应用服务
- 基于Ubuntu16.04的GeForce GTX 1080驱动安装,遇到的问题及对应的解决方法
- 反三角函数在线计算机,arcsin计算器(反三角函数计算器在线)
- SQL Server 【不允许保存更改】问题解决图解
- 苹果笔记本怎么找文件夹_苹果电脑的文件存在哪里_苹果电脑把文件放到哪-win7之家...
- [转] 公务员80分申论万能模板(转给需要的人)
- 解决WPS在Linux下字体缺失
- 玩转iOS开发:iOS 10 新特性《Siri Kit Intents Extension UI》
- 生物信息学还是跨专业计算机,生物统计学与生物信息学的区别
- 字符串内穿插{}使用
- uniapp开发使用uni-icons添加自定义图标
- android 天气 没有广告,收集几款无广告的纯净天气App
热门文章
- java基本微信小程序的琴房预约管理系统 uniapp 小程序
- js以索引形式遍历map对象
- java hypot_Java StrictMath hypot()用法及代碼示例
- JavaScript实现爆炸碎片的 图片切换 效果
- 基于Python爬虫的大众点评商家评论的文本挖掘
- 关于Keil.STM32F1xx_DFP.1.0.5代码无法烧录解决办法
- 第八讲:期望最大化算法(EM algorithm)
- Excel获取Sheet名称公式
- Windows下使用Linux scp 命令
- gnuplot命令大全