开发者

how can I redirect example.com/ch to a subdirectory /rootdir/ch/?

开发者 https://www.devze.com 2023-04-03 18:05 出处:网络
I have issue with url rewrite. I have a site example.com that has a wordpress installed. I want to have another wordress instance in the subdirectory \"/ch-wordpress/\" and serve it via url \"example

I have issue with url rewrite. I have a site example.com that has a wordpress installed.

I want to have another wordress instance in the subdirectory "/ch-wordpress/" and serve it via url "example.com/ch/....".

I know there are a lot of question concerning url rewrite, but I wasn't able to find the one that can help me. Will be very thankful if anyone could help me a bit.

Here is a currect url rewrite text

<IfModule mod_rewrite.c>
RewriteE开发者_如何转开发ngine On
RewriteBase /

RewriteRule ^category/culture-news/(.*)$ /cognac-news/$1 [L,R=301]
RewriteRule ^category/bottles/(.*)$ /cognac-reviews/$1 [L,R=301]
RewriteRule ^category/rare-bottle-price-worth-information/(.*)$ /your-cognac-bottle/$1 [L,R=301]
RewriteRule ^category/history-region-production/(.*)$ /what-is-cognac/$1 [L,R=301]
RewriteRule ^category/cognac-drinks-cocktails/(.*)$ /cognac-drinks-cocktails/$1 [L,R=301]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


forget about .htaccess there's an easier way, creante an index.php in your public_html and paste this

<?php
header('Location: http://example.com/ch/....');
?
>

it will redirect the index to the directory that you want

EDIT

you would like to redirect example.com/ch/$1" to subfolder "/ch/

okay then, you have a folder called $1 create an index.php and place it in $1

<?php
header('Location: http://example.com/ch/');
?
>

even if $1 is a file and not a folder, you could place the code in it and you'll be redirected when you go to it

Just try it to see how it works.

0

精彩评论

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

关注公众号