简体   繁体   中英

.HTACCESS url rewrite - 4 simple rewrite rules are not working (GoDaddy+WordPress)

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.

Well, anything that you do in your top rules is simply being overwritten by the WordPress: RewriteRule . /index.php [L] 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM