开发者

mod_rewrite - can't combine rules

开发者 https://www.devze.com 2023-02-01 06:36 出处:网络
I have 3 rules: # DEL www. from URL RewriteCond %{HTTP_HOST} ^www\\.(.+)$ [NC] RewriteRule开发者_Go百科 ^(.*)$ http://%1/$1 [R=301,L]

I have 3 rules:

  # DEL www. from URL
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
  RewriteRule开发者_Go百科 ^(.*)$ http://%1/$1 [R=301,L] 

  # DEL /index.php fron URL
  RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
  RewriteRule ^(([^/]+/)*)index\.php$ http://some-site.kiev.ua/$1 [R=301,L]

  # ADD / to URL
  RewriteRule  ^([^.]+[^./])$ /$1/  [R=301,L]

All the rules work individually, but when you use them at the same time - there is a looping and the site don't open...

Help please to combine them


This doesn't make sense to me:

# DEL /index.php fron URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://some-site.kiev.ua/$1 [R=301,L]

If you want to remove /index.php from URLs, you can just use

RewriteRule ^(.*)/index\.php$ $1

Also, your first rule adds an extra slash at the beginning of the path. Probably doesn't matter, but still.

0

精彩评论

暂无评论...
验证码 换一张
取 消