简体   繁体   English

通过htaccess重定向,其中IP不是&&删除index.php

[英]redirect via htaccess where IP is not && remove index.php

I usually use this htaccess file to remove index.php from my URLs in ExpressionEngine 我通常使用此htaccess文件从ExpressionEngine中的URL中删除index.php

AddType video/ogg .ogv
AddType video/mp4 .mp4
AddType video/webm .webm

AcceptPathInfo On

Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On

Options +FollowSymLinks

# Looks for files and directories that do not exist
# and provide the segments to the index.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/index.php
RewriteCond $1 !.(css|js|png|jpe?g|gif|ico)$ [NC]
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>  

While that works great, before we move this site into production, we're directing all traffic to the given url to another via this htaccess file 尽管效果很好,但在将该站点移入生产环境之前,我们正在通过此htaccess文件将所有访问该网址的流量定向到另一个网址

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteRule ^(.*)$ http://www.anotherdomain.com/ [R=301,NC]

My own ip address is replacing the localhost call so that I can access the site. 我自己的IP地址正在替换localhost呼叫,以便我可以访问该站点。

Basically what I'm looking for is a combination of these 2 that will remove index.php from my URLs for me but still redirect everyone else. 基本上,我正在寻找的是这两个的结合,这将为我从URL中删除index.php,但仍然重定向其他所有人。

Thanks, Steven 谢谢,史蒂文

Found that this works great: 发现这很好用:

RewriteEngine on

# If your IP address matches any of these - then dont re-write
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1 
RewriteRule ^(.*)$ http://www.anothersite.com/ [R=302,L]


# do not rewrite links to the assets and theme files
RewriteCond $1 !^(assets|themes|images)

# do not rewrite for php files in the document root, robots.txt etc
RewriteCond $1 !^([^\..]+\.php|robots\.txt|crossdomain\.xml)

# but rewrite everything else
RewriteRule ^(.*)$ index.php/$1 [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM