我的.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=$1 [L]
RewriteRule ^cart/([^/\.]+)/?$ cart.php?tbid=$1 [L]
</IfModule>
现在,我已经构建了指向例如此URL的链接
http://example.com/store/&amp;我希望此链接打开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 ^(.*)$ $1.php
RewriteRule ^store/([^/\.]+)/?$ storage.php?taid=$1 [L]
RewriteRule ^cart/([^/\.]+)/?$ cart.php?tbid=$1 [L]
</IfModule>
但问题是我遇到了重定向循环问题。我知道&#34; store&#34;在这里被用于两个不同的目的。一个只是在url&amp;中显示一个指向store.php文件。我想要网址 example.com/store / &amp; example.com/store / 打开store.php&amp; example.com/store/someparameter 到storage.php(工作正常)。
答案 0 :(得分:0)
你需要修复你的病情。 %{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}/$1\.php -f
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^store/([^/\.]+)/?$ storage.php?taid=$1 [L]
RewriteRule ^cart/([^/\.]+)/?$ cart.php?tbid=$1 [L]
</IfModule>