我的网站有以下结构
site
|-- .htaccess
|-- index.php
|-- other files and directories
index.php
文件用于每个重定向。我如何使用修改.htaccess
仅在有人想要访问mydomain.com/desiredLink
而不是有人使用mydomain.com
或mydomain.com/otherlink
时才重定向到mydomain.com/index.php?stuff
?
当前.htaccess内容如下:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|resources|assets|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
答案 0 :(得分:1)
您可以使用:
RewriteEngine on
RewriteBase /
# redirect root URL
RewriteRule ^/?$ /desiredLink [L,R]
# other than root URL
RewriteCond $1 !^(index\.php|resources|assets|robots\.txt) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php/$1 [L]