网址具有两次文件名时出现内部服务器错误

问题描述:

当我从URL写入两次文件名时,出现500 Internal Server Error。

I am getting 500 Internal Server Error when i wrote the twice file name from the url.

我正在为用户配置文件URL使用以下RewriteRule:

I am using the following RewriteRule for the user Profile url:

RewriteRule ^profile/([^/]+)/?$ profile.php?username=$1 [L,QSA,NC]  
RewriteRule ^profile/(followers|friends|saved|stories)/([^/]+)/?$ $1.php?username=$2 [L,QSA,NC]

该规则在此链接下工作正常:

The Rules working working fine with this link:

https://www.thewebsiteurl.com/profile/username

但是如果我写了像这样的文件名两次

But if i wrote the file name twice like this

https://www.thewebsiteurl.com/profile/profile/username

然后我收到500内部服务器错误。

then i am getting the 500 Internal Server Error.

是这里有任何答案可以解决此问题吗?

Is there any answer here to fix this problem ?

这是我的全部HTACCESS代码:

Here is my Full of my HTACCESS codes:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /

ErrorDocument 404 https://www.websiteurl.com/sources/not-found.php          
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=302,NE,L]

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*)index\.php$ /$1 [L,R=302,NC,NE]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteRule ^profile/([^/]+)/?$ profile.php?username=$1 [L,QSA,NC]  
RewriteRule ^profile/(followers|friends|saved|stories)/([^/]+)/?$ $1.php?username=$2 [L,QSA,NC]    


RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L] 


<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin '*'
</IfModule>


规则在我看来已经不错%{REQUEST_FILENAME} .php 的服务器由于文件名解析问题而无法正常工作。

Rules appear to fine though I have seen in some web servers that %{REQUEST_FILENAME}.php doesn't work properly due to file name resolution issues.

尝试将规则更改为:

RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]