Apache .htaccess中的条件重定向规则
我需要在.htaccess文件中应用以下规则-Apache .htaccess中的条件重定向规则,apache,.htaccess,Apache,.htaccess,我需要在.htaccess文件中应用以下规则- 如果url是mysite.com 如果url是mysite.com/index.php或mysite.com/anypage.anyextension 如果url在域后有单词admin作为mysite.com/admin/… 如果url的模式为mysite.com/anyword/或mysite.com/anyword则重定向到mysite.com/somewhere/somepage.php?slug=anyword .htaccess对我来
- 如果url是
mysite.com
- 如果url是
或mysite.com/index.php
mysite.com/anypage.anyextension
- 如果url在域后有单词admin作为
mysite.com/admin/…
- 如果url的模式为
或mysite.com/anyword/
则重定向到mysite.com/anyword
mysite.com/somewhere/somepage.php?slug=anyword
有人能帮你吗?如果你想让一个特定的文件夹执行重定向,例如,模板将是一个新闻文件夹
RewriteEngine On
RewriteRule ^news/([A-Za-z0-9-]+)/?$ /news/index.php?slug=$1 [NC,L,QSA] # Process posted item
这会将yousite.com/news/my first article
重定向到yoursite.com/news/index.php?slug=my first article
只需确保用实际处理命令的页面替换news和index.php