鉴于以下设置,我想做一个我无法工作的mod_rewrite:
我有一个域名,例如“example.org”指向共享托管环境中的目录,例如example/
具有以下文件结构:
example/
index.php
.htaccess
现在应将example.org/test
之类的网址重写为example.org/index.php?p=test
。我想出的是以下内容:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z]+)$ index.php?p=$1 [L,QSA]
不幸的是打开例如Firefox中的example.org/test
会导致以下错误:
页面未正确重定向
Firefox检测到服务器正在以永远无法完成的方式重定向此地址的请求。
但是,如果我在匹配部分前面加上这样的前缀:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^prefix/([a-z]+)$ index.php?p=$1 [L,QSA]
然后我可以打开例如example.org/prefix/test
我已尽快与index.php?p=test
一起投放,但未正确引用CSS和JavaScript等其他资源。
谁可以提供帮助?