Pie*_*tup 1 apache .htaccess mod-rewrite codeigniter
我知道这个问题可能已经被问了几次,但是我需要一个针对CodeIgniter的特定解决方案,使用.htaccess文件将每个请求发送到index_failsafe.php文件而不是普通的index.php,但仅限于url不以'admin'开头.例:
在案例1中:
RewriteRule ^.*$ index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)
在案例2中:
RewriteRule ^.*$ index_failsafe.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)
我的重写条件是:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Run Code Online (Sandbox Code Playgroud)
是否有可能做到这一点?
Lau*_*nce 11
我个人通过IP来做 - 所以我可以让我的网站脱机,但我仍然可以完全访问它(测试新功能并确保它在恢复之前工作)
RewriteEngine on
# For maintenance:
# If your IP address is 1.1.1.1 - then dont re-write
RewriteCond %{REMOTE_ADDR} !^1\.1\.1\.1
# If the person is requesting the maintenance page, also dont rewrite (prevent loops)
RewriteCond %{REQUEST_URI} !/maintenance.html$
# Otherwise rewrite all requests to the maintenance page
RewriteRule $ /maintenance.html [R=302,L]
# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(assets)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond $1 !^([^\..]+\.php|robots\.txt|maintenance\.html)
# but rewrite everything else
RewriteRule ^(.*)$ index.php/$1 [L]
Run Code Online (Sandbox Code Playgroud)
只是改变!^ 1.1.1.1到你当前的IP.即!^ 121.65.56.65
如果您不确定您的IP是什么 - 只需谷歌"我的IP是什么" - 它将显示为第一次点击
但就你的具体问题而言 - 这应该有效:
RewriteCond %{REQUEST_URI} !/admin$
RewriteRule $ /index_failsafe.php [R=302,L]
Run Code Online (Sandbox Code Playgroud)
编辑:
| 归档时间: |
|
| 查看次数: |
2590 次 |
| 最近记录: |