Swap two URLs with each other

时间:2016-08-31 12:27:30

标签: .htaccess

I have two pages:

  • http:// example.com containing content generated by CMS

  • http:// example.com/static-page/10 which is static page created in CMS

I would like to show my static page under main address (http:// example.com) and do it without redirecting (so user wouldn't see /static-page/10 in URL) and display my current main page in URL for example http:// example.com/info.
Is it possible?

Thanks in advance.

PS: reputation doesn't allow me to post multiple links, so I have broken them with a space

Update: My current .htaccess (generated by CMS):

Options -Indexes
RewriteEngine On

RewriteCond %{QUERY_STRING} ^$ 
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$

RewriteRule ^webapi/net-soap.*$ api.php?objects=1 [QSA,NC,L]
RewriteRule ^webapi/soap.*$ api.php [NC,L]
RewriteRule ^webapi/json.*$ api.php [NC,L]
RewriteRule ^webapi/rest.*$ api.php [NC,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

2 个答案:

答案 0 :(得分:0)

试试这个我假设index.php是你的主站点索引

RewriteEngine on
RewriteRule %{QUERY_STRING} ^$
RewriteRule ^$ /static-page/10
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l        
RewriteRule ^info$ index.php

答案 1 :(得分:0)

你可以尝试这样的事情:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^$ /info
RewriteRule ^static-page/10$ /