简体   繁体   English

.htaccess重定向404页面未找到

[英].htaccess redirect 404 page not found

I am having some issues with my .htaccess file. 我的.htaccess文件有问题。 For some reason, some domains work while others give me 404 page not found error. 由于某些原因,某些域正常工作,而另一些则给我404页面未找到错误。

So currently I am entering my domains like this: 因此,目前我正在这样输入我的域:

http://mywebsite.com/domain/google.com

Which should redirect to: 应该重定向到:

http://mywebsite.com/whois.php?domain=google.com

Having whois.php?domain=google.com with any domain doesn't give me a 404 error but on some domains I get 404 error with domain/google.com . 使用whois.php?domain=google.com与任何域都不会给我404错误,但是在某些域上domain/google.com却会导致404错误。 So I narrowed it down to my .htaccess being at fault. 所以我把它缩小到我的.htaccess是错误的。

Here is how my .htaccess looks like: 这是我的.htaccess样子:

RewriteEngine On
RewriteRule ^/?domain/([^/d]+)/?$ /whois.php?domain=$1 [L,QSA]

I have tried several different things including adding: 我尝试了几种不同的方法,包括添加:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ %{REQUEST_FILENAME} [L]

Any help on this would be appreciated. 任何帮助,将不胜感激。

Try this: 尝试这个:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(domain)/(.*)$  /whois.php?domain=$2 [L,QSA]

So basically whatever comes after domain you pass it as a param to your script. 因此,基本上任何域之后的内容都将其作为参数传递给脚本。

Explanation of Lines 2-4 第2-4行的说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM