-2

我想使用 mod-rewrite 来转换:

https://newbootstrap.com/quiz 

到:

https://newbootstrap.com/index.php?url=quiz 

这是我的 .htaccess:

    Options +FollowSymlinks
    Options -Indexes

    AddType text/x-component .htc

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    </IfModule>

    RewriteEngine On
    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/rss+xml

    <IfModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ 
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text\.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image\.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 
    </IfModule>

    <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
    Header set Cache-Control "max-age=2592000"
    </FilesMatch>

    #Запрет перехода с определенного сайта
    #<IfModule mod_rewrite.c>
    #RewriteEngine on
    #RewriteCond %{HTTP_REFERER} bannedurl1.com [NC,OR]
    #RewriteCond %{HTTP_REFERER} bannedurl2.com [NC,OR]
    #RewriteRule .* - [F]
    #</ifModule>
4

2 回答 2

2

RewriteRule ^quiz$ /index.php?url=quiz [L]

或者,如果这是任何请求的通用规则:

RewriteRule ^(.+)$ /index.php?url=$1 [L]

于 2013-06-09T07:59:01.520 回答
1

实现此目的的完整 .htaccess 文件将是:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.+)$ /index.php?url=$1 [L]
</IfModule>
于 2018-06-28T00:55:26.817 回答