首先,您必须确保在 apache 中启用了 rewrite_module 和 dir_module。然后检查您的 httpd.conf 文件以确保这些行存在:
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule dir_module modules/mod_dir.so
然后设置值DirectoryIndex
以包含目标文件(以 index.php 为例)
<IfModule dir_module>
DirectoryIndex index.php ...
</IfModule>
这是 .htaccess 文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|assets|uploads|cloudfront\.php)
RewriteRule ^(.*)$ index.php/$1 [L]
这会将您的 URI 值转发到目标文件 [index.php],然后在那里进行处理。在示例中,robots\.txt|assets|uploads|cloudfront\.php
不会被转发到 index.php,而是会被视为普通的目录请求。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句