Mod Rewrite 在共享 Linux 服务器中无法使用 .htaccess 工作
我正在使用共享的 Linux 主机,并创建了指向根文件夹内的 /hrms 文件夹的子域。
现在,我仅针对此子域设置了一个 mod 重写条件,如下所示:
RewriteEngine On
RewriteBase /hrms/
RewriteCond %{REQUEST_URI} !^/static/images
RewriteCond %{REQUEST_URI} !^/static/js
RewriteCond %{REQUEST_URI} !^/static/css
RewriteRule ^/(.*)$ /index.php?request=$1 [PT,QSA,L]
但是当我尝试登录时收到此错误:
未找到 在此服务器上找不到请求的 URL /login。 此外,在尝试使用 ErrorDocument 处理请求时遇到 404 Not Found 错误。
此外,我尝试检查 .htaccess 是否已解析,当我添加一些垃圾时,服务器给出了 500 内部错误,因此.htaccess 也被解析并且不是问题。
我已经在 google 和 stackoverflow 中搜索了相同的错误,但没有发现我正在做的错误。
请帮忙!谢谢...
阿图尔·亚达夫。 atulmy.com
I'm using a shared linux hosting and have created subdomain which points to /hrms folder inside the root folder.
Now, I've a mod rewrite condition for this subdomain only which goes like this:
RewriteEngine On
RewriteBase /hrms/
RewriteCond %{REQUEST_URI} !^/static/images
RewriteCond %{REQUEST_URI} !^/static/js
RewriteCond %{REQUEST_URI} !^/static/css
RewriteRule ^/(.*)$ /index.php?request=$1 [PT,QSA,L]
But I'm getting this error when I try to login:
Not Found
The requested URL /login was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Also, I tried to check if .htaccess is parsed and when I added some junk, the server gave 500 Internal error, so .htaccess is also parsed and is not a problem.
I already searched for same error in google and stackoverflow, but didn't found the mistake I'm doing.
Please help! Thanks...
Atul Yadav.
atulmy.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设您的共享托管服务 (SHS) 提供商提供了一些子域映射器控制台,以便完成
http://hrms.atulmy.com/
到~/hrms
的映射通过其 vhost 配置中特定于 SHS 的RewriteMap
。.htaccess
来验证您的假设;将 phpinfo 脚本放入~/hrms
中,并执行http://hrms.atulmy.com/phpinfo.php
http://hrms.atulmy 开始。 com/login
有一个 REQUEST_URI/login
您的RewriteBase
应该只是/
并且您应该使用~/hrms/ .htaccess
.htaccess
重写规则中的^/
。.htaccess
重写规则中使用相对替换字符串,除非您想要重写到不同的目录层次结构。http://atulmy.com/hrms/
进行正确的重定向index.php
上循环,因此您需要一个保护条件,最简单的方法是使用文件存在检查,这样就不需要现有的静态检查。给予:
如果您不喜欢这个,则将最后一个条件替换为:
I assume that your shared hosting service (SHS) provider provides some subdomain mapper console so the mapping of
http://hrms.atulmy.com/
to~/hrms
is done through and SHS-specificRewriteMap
in its vhost config..htaccess
; dropping a phpinfo script into~/hrms
and doing ahttp://hrms.atulmy.com/phpinfo.php
http://hrms.atulmy.com/login
has a REQUEST_URI/login
yourRewriteBase
should be simply/
and you should use~/hrms/.htaccess
^/
in an.htaccess
rewrite rule..htaccess
rewrite rule unless you want to rewrite to a different directory hierarchy.http://atulmy.com/hrms/
index.php
so you need a guard condition, the easiest way is to use a file existence check which removes the need for the existing static checks .Giving:
If you don't like this then replace this last condition by:
这个怎么样:
?告诉我是否有效。
How about this:
? Tell me if it works.
你能发布更多你的 Htaccess 文件吗?如果我尝试:
它会将我发送到:
Can you post more of your Htaccess file? If I try:
It sends me to: