.HTACCESS url rewrite - 4 simple rewrite rules are

2019-07-29 04:20发布

I wonder if my rewrite rules are incorrect since they are not working on my Godaddy shared server?

I have four very basic .htaccess URL rewrite rules. Whenever the user types/clicks on the link:

  1. Beautiful SEO (desired) link http://www.electriccarlos.com/albums/
    is actually http://www.electriccarlos.com/type/audio/

  2. Beautiful SEO (desired) link http://www.electriccarlos.com/discography/
    is actually http://www.electriccarlos.com/type/audio/

  3. Beautiful SEO (desired) link http://www.electriccarlos.com/gallery/
    is actually http://www.electriccarlos.com/type/gallery/

  4. Beautiful SEO (desired) link http://www.electriccarlos.com/videos/
    is actually http://www.electriccarlos.com/type/video/


.htaccess file:

# BEGIN Omar Juvera
RewriteEngine On
    # albums
RewriteRule    ^albums/?$       type/audio/     [NC,L]
RewriteRule    ^discography/?$  type/audio/     [NC,L]
    # gallery
RewriteRule    ^gallery/?$      type/gallery/   [NC,L]
    # videos
RewriteRule    ^videos/?$       type/video/     [NC,L]
# END Omar Juvera


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

The .htaccess file is properly configured and RedirectMatch is active.

1条回答
放我归山
2楼-- · 2019-07-29 05:05

Well, anything that you do in your top rules is simply being overwritten by the WordPress: RewriteRule . /index.php [L]

Which rewrites everything to /index.php except for existing files and directories.

You're going to have to speak very nicely to WordPress and ask it to do this for you! If you don't know how to do that I suggest starting another question about how to do this with WordPress.

查看更多
登录 后发表回答