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

不想你离开。 提交于 2020-01-15 09:54:09

问题


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:


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.



来源:https://stackoverflow.com/questions/43855644/htaccess-url-rewrite-4-simple-rewrite-rules-are-not-working-godaddywordpres

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!