문제

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top