简体   繁体   中英

htaccess rewrite rule for url not working

I am trying to make website.com/cms or website.com/cms/ go to website.com/cms/administrator/

On other websites this is working fine but for some reason I can't get it to work on this one.

My htaccess:

DirectoryIndex
RewriteEngine  on

#Indexes uitzetten
Options -Indexes

#Cross site access toestaan
Header set Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"

#CMS rewrite
RewriteRule ^cms/$ /cms/administrator [L]

#Website name

DirectoryIndex index.php

RewriteRule         ^projecten/(.*).html projecten.php?alias=$1 [L]
RewriteRule         ^project/(.*).html project.php?alias=$1 [L]
RewriteRule         ^informatie/(.*).html over-ons.php?alias=$1 [L]
RewriteRule         ^(.*).html dienst.php?alias=$1 [L]

And the rule that isn't working:

RewriteRule ^cms/$ /cms/administrator [L]

I tried to clear cache but whatever I try, it still just goes to /cms instead of /cms/administrator. Am I missing something?

It rewrites URL, so the request to "cms" is a request to "cms/administrator" under the hood. If you want to redirect, add R flag with 301 (permament) or 302 (temporary) attribute.

RewriteRule ^cms/$ /cms/administrator [L,R=301]

Read here (flags section)

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