我想为htaccess
创建自定义规则,以便主文件夹中请求的所有网址(例如localhost/asfsd
)都会重定向到localhost/index.php?url=asfsd
,但如果用户输入以下网址{ {1}}然后必须将其转发至localhost/asfsd-
。这是我当前的localhost/info.php?url=asfsd
配置:
.htaccess
答案 0 :(得分:0)
试试这个
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\-$ info.php?url=$1 [L,QSA]
RewriteRule ^(.*) index.php?url=$1 [L,QSA]
答案 1 :(得分:0)
您可以尝试以下两条规则:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)-$ /info.php?url=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?url=$1 [L,QSA]