这是我目前的整个.htaccess文件:
RewriteEngine on
Redirect /index.php /home
RewriteRule ^home$ /index.php?page=home
RewriteRule ^education$ /index.php?page=home&filter=1
RewriteRule ^skills$ /index.php?page=home&filter=2
RewriteRule ^projects$ /index.php?page=home&filter=3
RewriteRule ^experience$ /index.php?page=home&filter=4
RewriteRule ^contact$ /index.php?page=contact
我目前正在使用顶部重定向来重定向: www.codeliger.com/index.php到www.codeliger.com/home看起来更好。 (有更好的方法吗?)
问题是它还将img.codeliger.com重定向到codeliger.com/home。
如何防止重定向子域?
答案 0 :(得分:2)
是的,您可以将第一条规则替换为:
RewriteCond %{HTTP_HOST} ^(www\.)?codeliger\.com$ [NC]
RewriteCond %{THE_REQUEST} \s/(index\.php)?[\s?] [NC]
RewriteRule ^ /home? [L,R]
RewriteRule ^home/?$ /index.php?page=home [L]
RewriteRule ^education/?$ /index.php?page=home&filter=1 [L]
RewriteRule ^skills/?$ /index.php?page=home&filter=2 [L]
RewriteRule ^projects/?$ /index.php?page=home&filter=3 [L]
RewriteRule ^experience/?$ /index.php?page=home&filter=4 [L]
RewriteRule ^contact/?$ /index.php?page=contact [L]