dongyan1808 2017-11-03 15:51
浏览 116
已采纳

使用Wordpress Rewrite或.htaccess重写URL

I'm trying to append to wordpress an additional parameter into my URL. For example, I have the URL: http://example.com I want to change that to URL: http://example.com/this-example/

I'm thinking I can do this is in htaccess along the lines of a rewrite condition, but i'm unsure how to go about this. This is what I was thinking here.

Htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine on
RewriteRule ^/this-example/(.*)/ /index.php?$1 [L]
</IfModule>
Options -Indexes
  • 写回答

1条回答 默认 最新

  • doumeng1089 2017-11-03 19:07
    关注

    You can try this:

    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{THE_REQUEST} !^/this-example [NC]
        # use your own host here, for me is 192.68.10.10
        RewriteCond %{HTTP_HOST} 192\.168\.10\.10$ [NC] 
        RewriteRule !^this-example/ /this-example%{REQUEST_URI} [L,R,NE]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^this-example/(.*)$ $1 [L,QSA]
    </IfModule>
    
    Options -Indexes
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?