简体   繁体   中英

.htaccess query string rewrite 404

I have an htaccess file that should rewrite something like something.com/viewpost/post/5 to index.php?action=viewpost&post=5 and it works fine, but if the url has any more queries, it gives a 404 error.

My .htaccess

RewriteEngine On
RewriteRule ^([a-zA-Z0-9-=_?]+)/?$ index.php?action=$1 
RewriteRule ^([a-zA-Z0-9-=_?]+)/([a-zA-Z0-9-=_?]+)/([a-zA-Z0-9-=_?]+)/?$ index.php?action=$1&$2=$3 #Rewrites urls like /viewpost/post/5
RewriteRule ^([a-zA-Z0-9-=_?]+)/([a-zA-Z0-9-=_?]+)/([a-zA-Z0-9-=_?]+)/([a-zA-Z0-9-=_?]+)/([a-zA-Z0-9-=_?]+)/?$ index.php?action=$1&$2=$3&$4=$5 #rewrites URLs like /viewpost/post/5/mode/lock

What I first thought was the issue was that the shorter rewrite was stopping the longer one from working, but I removed it and got the same result.

I'm pretty new to htaccess, so as far as I know this would be unique to me unless someone else uses the same system as I do. I did google my issue and found nothing that looked to be the same as my own.

EDIT: I had forgotten to ask also, if this would be due to the fact that /viewpost/post/5 is valid, so going any further would result in looking for a directory?

Update: Now it's just not working all of the sudden. Also, the website is on cloudflare, would that be a problem?

I guess this had to do with FileZilla. The file was not uploaded when I had though it was and there were commented and missing lines in the file that was on the server.

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