用几个变量重写htaccess

时间:2015-06-14 17:40:31

标签: php apache .htaccess mod-rewrite rewrite

我在htaccess中有好的重写配置问题。

我有4个变量:

$lang,
$page,
$bookmarkTitle,
$title.

我想得到这样的链接:

  1. 域/ $ page.html中
  2. 域/ $ LANG /
  3. 域/ $ LANG / $ page.html中
  4. 域/ $页/ $ bookmarkTitle.html
  5. 域/ $ LANG / $页/ $ bookmarkTitle.html
  6. 域/ $页/ $ bookmarkTitle / $ title.html
  7. 域/ $ LANG / $页/ $ bookmarkTitle / $ title.html
  8. 问题在于3和4,或5和6,因为我不知道如何检查应该打开哪个变量

    #Linki
    
    RewriteRule ^(.*)/(.*).html$ index.php?lang=$1&page=$2 [L]
    RewriteRule ^(.*)/$ index.php?lang=$1 [L]
    RewriteRule ^(.*).html$ index.php?page=$1 [L]
    
    #Pojedyncza Oferta
    
    RewriteRule ^(.*)/(.*)/(.*)/(.*).html$ index.php?lang=$1&page=$2&bookmarkTitle=$3&title=$4 [L]
    RewriteRule ^(.*)/(.*)/(.*).html$ index.php?page=$1&bookmarkTitle=$2&title=$3 [L]
    
    #Aktualnosci, Oferta i Galeria
    
    RewriteRule ^(.*)/(.*)/(.*).html$ index.php?lang=$1&page=$2&bookmarkTitle=$3 [L]
    RewriteRule ^(.*)/(.*).html$ index.php?page=$1&bookmarkTitle=$2 [L]
    

    我尝试了这段代码,但它没有工作属性。

    修改

    Options FollowSymLinks
    RewriteEngine On
    
    #CMS
    
    #CMS pojedycznych ofert - jezyki
    RewriteRule ^CMS/([a-zA-Z]{2})/(.*)/(.*)/dodaj/(.*).html$ CMS/index.php?lang=$1&page=$2&bookmarkTitle=$3&Add=$4 [L]
    RewriteRule ^CMS/([a-zA-Z]{2})/(.*)/(.*)/edytuj/(.*).html$ CMS/index.php?lang=$1&page=$2&bookmarkTitle=$3&Edit=$4 [L]
    RewriteRule ^CMS/([a-zA-Z]{2})/(.*)/(.*)/usun/(.*).html$ CMS/index.php?lang=$1&page=$2&bookmarkTitle=$3&Delete=$4 [L]
    
    #CMS zakładek - jezyki
    RewriteRule ^CMS/([a-zA-Z]{2})/dodaj/(.*).html$ CMS/index.php?lang=$1&page=$2&Add=$3 [L]
    RewriteRule ^CMS/([a-zA-Z]{2})/edytuj/(.*).html$ CMS/index.php?lang=$1&page=$2&Edit=$3 [L]
    RewriteRule ^CMS/([a-zA-Z]{2})/usun/(.*).html$ CMS/index.php?lang=$1&page=$2&Delete=$3 [L]
    
    #Aktualnosci, Oferta i Galeria - jezyki
    RewriteRule ^CMS/([a-zA-Z]{2})/(.*)/(.*).html$ CMS/index.php?lang=$1&page=$2&bookmarkTitle=$3 [L]
    
    #Linki - jezyki
    RewriteRule ^CMS/([a-zA-Z]{2})/(.*).html$ CMS/index.php?lang=$1&page=$2 [L]
    
    #CMS pojedycznych ofert
    RewriteRule ^CMS/(.*)/(.*)/dodaj/(.*).html$ CMS/index.php?page=$1&bookmarkTitle=$2&Add=$3 [L]
    RewriteRule ^CMS/(.*)/(.*)/edytuj/(.*).html$ CMS/index.php?page=$1&bookmarkTitle=$2&Edit=$3 [L]
    RewriteRule ^CMS/(.*)/(.*)/usun/(.*).html$ CMS/index.php?page=$1&bookmarkTitle=$2&Delete=$3 [L]
    
    #CMS zakładek
    RewriteRule ^CMS/(.*)/dodaj/(.*).html$ CMS/index.php?page=$1&Add=$2 [L]
    RewriteRule ^CMS/(.*)/edytuj/(.*).html$ CMS/index.php?page=$1&Edit=$2 [L]
    RewriteRule ^CMS/(.*)/usun/(.*).html$ CMS/index.php?page=$1&Delete=$2 [L]
    
    #Aktualnosci, Oferta i Galeria
    RewriteRule ^CMS/(.*)/(.*).html$ CMS/index.php?page=$1&bookmarkTitle=$2 [L]
    
    #Linki
    RewriteRule ^CMS/([a-zA-Z]{2})/$ CMS/index.php?lang=$1 [L]
    RewriteRule ^CMS/(.*).html$ CMS/index.php?page=$1 [L]
    
    
    #STRONA
    
    #Pojedyncza Oferta - jezyki
    RewriteRule ^([a-zA-Z]{2})/(.*)/(.*)/(.*).html$ index.php?lang=$1&page=$2&bookmarkTitle=$3&title=$4 [L]
    
    #Aktualnosci, Oferta i Galeria - jezyki
    RewriteRule ^([a-zA-Z]{2})/(.*)/(.*).html$ index.php?lang=$1&page=$2&bookmarkTitle=$3 [L]
    
    #Linki - jezyki
    RewriteRule ^([a-zA-Z]{2})/(.*).html$ index.php?lang=$1&page=$2 [L]
    
    #Pojedyncza Oferta
    RewriteRule ^(.*)/(.*)/(.*).html$ index.php?page=$1&bookmarkTitle=$2&title=$3 [L]
    
    #Aktualnosci, Oferta i Galeria
    RewriteRule ^(.*)/(.*).html$ index.php?page=$1&bookmarkTitle=$2 [L]
    
    #Linki
    RewriteRule ^([a-zA-Z]{2})/$ index.php?lang=$1 [L]
    RewriteRule ^(.*).html$ index.php?page=$1 [L]
    
    <FilesMatch "\.(htm|html|php)$">
        <IfModule mod_headers.c>
            BrowserMatch MSIE ie
            Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
        </IfModule>
    </FilesMatch>
    ErrorDocument 404 /404.php
    
    ########## Start – Dostęp tylko z określonego adresu IP
    Order deny,allow
    Deny from all
    Allow from 77.253.2.83
    Allow from 93.105.11.2
    ########## Koniec – Dostęp tylko z określonego adresu IP
    

0 个答案:

没有答案