2016-11-13 71 views
0

以下代码很有用。然而,它需要很多时间才能完成数百个php文件。所有php文件的RewriteCond%{REQUEST_URI}

RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_URI} !^/abc.php 
RewriteCond %{REQUEST_URI} !^/index.php 
RewriteCond %{REQUEST_URI} !^/home.php 
RewriteCond %{REQUEST_URI} !^/settings.php 
RewriteCond %{REQUEST_URI} !^/messages.php 
... 
... 
... 
RewriteRule ^/?([a-zA-Z0-9\-=&[email protected]/.]+)/?$ abc.php?u=$1 [QSA,L] 

我必须逐行写入所有php文件。有没有简单的方法来做到这一切的所有PHP网页?

回答

0

是的,你可以使用:

RewriteEngine on 
RewriteBase/

# The request is not for a valid file/directory 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+?)/?$ abc.php?u=$1 [L,QSA] 

如果你想排除PHP文件,你可以使用:

RewriteCond %{REQUEST_URI} !\.php$ [NC] 
RewriteRule ^(.+?)/?$ abc.php?u=$1 [L,QSA] 
+1

感谢您Croises :) – Mert

相关问题