What is the description of the redirect using .htaccess?
I would like to redirect to 4) if there is access to 1) through 3).
I would also like to include the path following /sp/ in the redirect target as shown in 22)3.
However, directory sp does not exist.
If you need directory sp, creating directory sp is fine.
1) http://example.com/sp/
2) http://example.com/sp/index.php
3) http://example.com/sp/2015/01.php
4) http://example.com
http://example.com
is probably running the site.Place the .htaccess file in this root directory (that is, http://example.com/.htaccess
). The sp
directory is generally not required.
If you redirect from (1) to (3) to (4), the content is
RewriteRule^sp/(?:index\.php|2015/01\.php)?$/[L,R=301]
and so on.Also, if you do not misunderstand the purpose of the question, you would like to prohibit access to /sp/
and return it to the front page of the site.In this case, change the regular expression
RewriteRule^sp/.*?$/[L,R=301]
and so on.Now R=301
sets the redirect type, so set the appropriate settings for your purpose, such as 301,302.
I don't think you'll learn much if you write your answers like this, so I recommend you to experiment and learn how to use regular expressions and mod_rewrite by yourself.
© 2024 OneMinuteCode. All rights reserved.