simple redirect to default page with htaccess
-
05-10-2019 - |
문제
The htaccess file requires an entry at the end of /folder/
to redirect the page
example:
http://www.server.com/folder/"some-page-name"
If no page is defined as, then I want it to be "index" by default
the htacess
RewriteBase /folder/
RewriteRule ^(.*)$ subfolder/index.php/?page=$1 [L]
해결책
# there must be something after /folder/ for this to work
RewriteBase ^/folder/(.+)$ /folder/subfolder/index.php/?page=$1 [L]
# if there isn't, do a catch-all redirect (change to whatever "index by default" means)
RewriteRule ^/folder/$ /folder/index
다른 팁
If you want to check whether the file exists or not and redirect the users to the index (if is does not), use the following condition:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond .* index [R=301]
제휴하지 않습니다 StackOverflow