将页面重定向到另一个使用ip .htaccess的页面

问题描述 投票:0回答:2

我想用.htacces将页面(post)(domain.com/general/test/)重定向到(domain.com/general/test/2)

并使用ip,也就是说我只想对ip xx.xx.xx人进行重定向。

  • 我使用wordpress cms
  • 我使用permalink domain.com/category/postname

** mycode但没有工作:( **

RewriteEngine On  
RewriteCond %{REMOTE_ADDR} ^xx\.xx\.xx\.xx$    
RewriteRule ^test\ /test/2 [R,NC,L]
wordpress .htaccess redirect url-redirection permalinks
2个回答
0
投票

@穆罕默德

RewriteEngine On
RewriteCond %{HTTP_HOST} example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]


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

# END WordPress

RewriteEngine On  
#RewriteCond %{REMOTE_ADDR} ^xx\.xx\.xx\.xx$ 
RewriteCond %{REQUEST_URI} !/test/2   
RewriteRule ^test/ /test/2 [R,NC,L]

0
投票

试试这个 :

RewriteEngine On  
RewriteCond %{REMOTE_ADDR} ^xx\.xx\.xx\.xx$ 
RewriteCond %{REQUEST_URI} !/general/test/2   
RewriteRule ^general/test/ /general/test/2 [R,NC,L]
© www.soinside.com 2019 - 2024. All rights reserved.