2017-07-31 79 views
0

的htaccesss代码是如何工作的,以及他们如何使用重定向为什么使用的index.php链接 ?htaccess的重写是如何工作的

<IfModule mod_rewrite.c> 
RewriteEngine On 
#RewriteBase /XYZ/ 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
+0

的【什么是.htaccess文件?]可能的复制(https://stackoverflow.com/questions/13170819/what-is-htaccess-文件) – 2017-07-31 11:32:57

+0

其略有不同我认为 – Satish51

+0

我想你问过代码如何工作不是如何.htaccess的作品?对? –

回答

1
RewriteEngine On # Enable the rewrite engine 

RewriteBase /XYZ/ #The base url can also be called as root url 

RewriteRule ^index.php$ - [L] #Content between^$ are rewritten [L] is a flag 

RewriteCond %{REQUEST_FILENAME} !-f # Don't select files 

RewriteCond %{REQUEST_FILENAME} !-d #Don't select directory 

检查有关国旗在Apache的文档https://httpd.apache.org/docs/current/rewrite/flags.html

有更多的问题,问意见。

旁注 使用这个,如果你有多个条件

RewriteCond %{REQUEST_FILENAME} -d [OR] 
RewriteCond %{REQUEST_FILENAME} -f