簡體   English   中英

.htaccess www.mydomain.com/index.php?page=home到www.mydomain.com/home

[英].htaccess www.mydomain.com/index.php?page=home to www.mydomain.com/home

如何設置med .htaccess文件,以便將www.mydomain.com/index.php?page=home重寫為www.mydomain.com/home?

我已經嘗試過這段代碼,但是不喜歡我想要的。

在RewriteBase上的RewriteEngine /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php?page= [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule ^([^/]+)/? index.php [L,QSA]


    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?page=$1 [L]

您的第一個重定向規則不正確。 您可以使用:

RewriteEngine On
RewriteBase /

# Removes index.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} /index\.php\?page=([^\s&]+) [NC]
RewriteCond %{REQUEST_URI} !/system/.* [NC]
RewriteRule ^ /%1? [R=302,L,NE]

# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?page=$1 [L,QSA]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM