2016-11-13 114 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