开发者

htaccess redirect without changing url

开发者 https://www.devze.com 2023-02-05 10:22 出处:网络
I have few urls like http://www.mydomain.com/statecode1-folder1 I want to redirect it to /folder1/page but I want to show the the original urls as above in the browser address bar.

I have few urls like

http://www.mydomain.com/statecode1-folder1

I want to redirect it to /folder1/ page but I want to show the the original urls as above in the browser address bar.

Please note that I do not have folders statecode1-folder1 and statecode2-folder1

Currently I use the below .htaccess which redirects but it changes the address bar

#Options +FollowSymlinks 
RewriteEngine On
RewriteBase   /
RewriteCond  %{REQUEST_URI}   ^/ statecode1-folder1 $  
RewriteRule   ^(.+)  / folder1 [L]
RewriteCond  %{RE开发者_运维问答QUEST_URI}   ^/ statecode2-folder1 $  
RewriteRule   ^(.+)  / folder1 [L]


You shouldn't have spaces after slash! And the ending $ Maybe it is the problem? Normally, local redirect should work. Try something like this:

RewriteEngine On
RewriteBase   /
RewriteCond  %{REQUEST_URI}   ^/statecode1-folder1
RewriteRule   ^.*  /folder1 [L]
RewriteCond  %{REQUEST_URI}   ^/statecode2-folder1
RewriteRule   ^.*  /folder1 [L]


the answer is similar to this, at least you may try it:

   RewriteCond %{HTTP_HOST} ^Domain.com/statecode1-folder1 $
   RewriteRule ^(.*)  Domain.com/newpath [P] 

for more urls use $1 sign to ensure more than one(few) url(s) with different URIs.

0

精彩评论

暂无评论...
验证码 换一张
取 消