简体   繁体   中英

Rewriting url and htaccess (localhost)

I'm learning a tutorial in order to rewrite the url of my posts (ex: articles/presentation-et-demonstration-des-jeux-videos-a-venir-pour-l-annee-2018-516 instead of articles.php?billet=516presentation-et-demonstration-des-jeux-videos-a-venir-pour-l-annee-2018 ) but I'm receiving an error statement in local with the following message :

This page isn't working

localhost redirect too many times.

Try to delete cookies..

ERR_TOO_MANY_REDIRECTS

By my side, php.ini and httpd.conf are set to be use properly. Furthermore, I've deleted cookies in my navigator.

This is the code I'm using in my .htaccess which I put in the good root :

RewriteEngine On
RewriteRule articles/([a-zA-Z0-9\-]+)-([0-9]+) articles.php?id=$2 [L]

Could someone please give me a hand with this trouble ?

Thank you in advance,

it's not .htaccess error or .htaccess misswriting

this error

This page isn't working

localhost redirect too many times.

maybe happend cause the site always read header('location: url'); or window.location.href in javascript to the same direction/url .

like if you use header('location: index.php') in file index.php that mean everytime you read/open index.php you will be directed to the index.php and when you read/open again it will make you being redirected again. So the server prevent this with this error .

NOTE

Make sure you use header('location: url') correctly if you use it, since the .htaccess file make everything redirected throught article.php check if there was any redirecting function in your code .

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