apachehtaccess转发子文件夹
我想为htaccess创建一个自定义规则,以便在主文件夹(如localhost/asfsd)中请求的所有URL将重定向到localhost/index.php?URL=asfsd,但如果用户输入以下URL localhost/asfsd,则必须将其转发到localhost/info.php?URL=asfsd。以下是我当前的.htaccess配置:apachehtaccess转发子文件夹,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我想为htaccess创建一个自定义规则,以便在主文件夹(如localhost/asfsd)中请求的所有URL将重定向到localhost/index.php?URL=asfsd,但如果用户输入以下URL localhost/asfsd,则必须将其转发到localhost/info.php?URL=asfsd。以下是我当前的.htaccess配置: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQ
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?url=$1 [L,QSA]
试试这个
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\-$ info.php?url=$1 [L,QSA]
RewriteRule ^(.*) index.php?url=$1 [L,QSA]
您可以尝试以下两条规则:
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]
谢谢你,纽曼。。。但它仍然只将所有尾随URL转发到index.php。