需要正确的 .htaccess 配置

need correct .htaccess configuration

我的 .htaccess 文件中有以下几行可以完美运行。

ErrorDocument 413 error.php?413
ErrorDocument 414 error.php?414
ErrorDocument 500 error.php?500    
<IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews -Indexes
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php !-f
    RewriteRule ^store/([^/\.]+)/?$  storage.php?taid= [L]
    RewriteRule ^cart/([^/\.]+)/?$  cart.php?tbid= [L]
    </IfModule>

现在,我已经构建了 links 指向例如这个 url http://example.com/store/ & 我希望这个 link 打开 store.php 文件。为此,我编写了新代码,即

ErrorDocument 413 error.php?413
ErrorDocument 414 error.php?414
ErrorDocument 500 error.php?500
    <IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews -Indexes
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.php !-f
    RewriteRule ^(.*)$ .php
    RewriteRule ^store/([^/\.]+)/?$  storage.php?taid= [L]
    RewriteRule ^cart/([^/\.]+)/?$  cart.php?tbid= [L]
    </IfModule>

但问题是我遇到了重定向循环问题。我知道 "store" 在这里被用于两个不同的目的。一个只显示在 url 中,另一个用于指向 store.php 文件。我想要 url 的 example.com/store/ & example.com/store/ 打开 store.php & example.com/store/someparameter to storage.php (效果很好).

您需要修复您的状况。 %{REQUEST_FILENAME}-f 检查错误。你想要:

ErrorDocument 413 error.php?413
ErrorDocument 414 error.php?414
ErrorDocument 500 error.php?500
    <IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews -Indexes
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}/\.php -f
    RewriteRule ^(.*)$ .php [L]
    RewriteRule ^store/([^/\.]+)/?$  storage.php?taid= [L]
    RewriteRule ^cart/([^/\.]+)/?$  cart.php?tbid= [L]
    </IfModule>